Tagged: x
-
AuthorPosts
-
May 31, 2016 at 1:29 pm #1018620
asewellDSAParticipantAfter updating the X plugin, the recent_posts shortcode with count=”1″ will not save in Visual / Frontend editor. When entered in text mode and Updating it saves. However, if you simply go to the Frontend editor or the Visual Composer and simply click Update without editing anything, it will delete the count = 1 part of the shortcode. Post type is set to Posts. As a note, if count = 2 and up, everything works as it should. It’s only when count = 1.
Also, when selecting Post Count = 1 using the dropdown list and clicking save in the pop-up window, and then opening the window again, Post Count returns to – Select Option – in the dropdown.
Thanks in advance!
If you need any other information, please let me know.
May 31, 2016 at 2:31 pm #1018698
JadeModeratorHi there,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
June 1, 2016 at 9:30 am #1020097
asewellDSAParticipantThis reply has been marked as private.June 1, 2016 at 11:37 am #1020352
Nabeel AModeratorHi again,
To fix the issue, Please add this code to your child theme’s functions.php:
function x_shortcode_recent_posts_count_one( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'type' => 'post', 'count' => '', 'category' => '', 'offset' => '', 'orientation' => '', 'no_sticky' => '', 'no_image' => '', 'fade' => '' ), $atts, 'x_recent_posts' ) ); $allowed_post_types = apply_filters( 'cs_recent_posts_post_types', array( 'post' => 'post' ) ); $type = ( isset( $allowed_post_types[$type] ) ) ? $allowed_post_types[$type] : 'post'; $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-recent-posts cf ' . esc_attr( $class ) : 'x-recent-posts cf'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $count = ( $count != '' ) ? $count : 3; $category = ( $category != '' ) ? $category : ''; $category_type = ( $type == 'post' ) ? 'category_name' : 'portfolio-category'; $offset = ( $offset != '' ) ? $offset : 0; $orientation = ( $orientation != '' ) ? ' ' . $orientation : ' horizontal'; $no_sticky = ( $no_sticky == 'true' ); $no_image = ( $no_image == 'true' ) ? $no_image : ''; $fade = ( $fade == 'true' ) ? $fade : 'false'; $js_params = array( 'fade' => ( $fade == 'true' ) ); $data = cs_generate_data_attributes( 'recent_posts', $js_params ); $output = "<div {$id} class=\"{$class}{$orientation}\" {$style} {$data} data-fade=\"{$fade}\" >"; $q = new WP_Query( array( 'orderby' => 'date', 'post_type' => "{$type}", 'posts_per_page' => "{$count}", 'offset' => "{$offset}", "{$category_type}" => "{$category}", 'ignore_sticky_posts' => $no_sticky ) ); if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post(); if ( $no_image == 'true' ) { $image_output = ''; $image_output_class = 'no-image'; } else { $image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'entry-cropped' ); $bg_image = ( $image[0] != '' ) ? ' style="background-image: url(' . $image[0] . ');"' : ''; $image_output = '<div class="x-recent-posts-img"' . $bg_image . '></div>'; $image_output_class = 'with-image'; } $output .= '<a class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"', csl18n() ), the_title_attribute( 'echo=0' ) ) ) . '">' . '<article id="post-' . get_the_ID() . '" class="' . implode( ' ', get_post_class() ) . '">' . '<div class="entry-wrap">' . $image_output . '<div class="x-recent-posts-content">' . '<h3 class="h-recent-posts">' . get_the_title() . '</h3>' . '<span class="x-recent-posts-date">' . get_the_date() . '</span>' . '</div>' . '</div>' . '</article>' . '</a>'; endwhile; endif; wp_reset_postdata(); $output .= '</div>'; return $output; } add_action('init', 'set_default_value_to_one', 9999999 ); function set_default_value_to_one () { remove_shortcode( 'recent_posts' ); add_shortcode( 'recent_posts', 'x_shortcode_recent_posts_count_one' ); }Let us know how this goes!
June 1, 2016 at 4:35 pm #1020860
asewellDSAParticipantThis reply has been marked as private.June 2, 2016 at 12:23 am #1021495
RadModeratorHi there,
It’s due to Visual Composer’s behavior. When the default value is set it will then remove it, a default value is treated as “nothing changed” since user let the default value. Then VC remove it.
It’s the same as empty value as default since it’s default then it will be removed. But this time, 1 is the default value.
But, we can add some workaround if count is empty, but this is only applicable to rendering and not directly to the Visual Composer’s options.
Change this code
$count = ( $count != '' ) ? $count : 3;to this,
$count = ( $count != '' ) ? $count : 1;Cheers!
June 2, 2016 at 8:15 am #1022109
asewellDSAParticipantThat worked! Thank all of you for all of your help. I really appreciate it!
June 2, 2016 at 10:32 am #1022380
RupokMemberYou are welcome!
Glad that it helped. Feel free to let us know if you face any other issue. We’ll be happy to assist you.
Thanks for using X.
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1018620 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
