-
AuthorPosts
-
August 21, 2014 at 9:39 pm #89811
I have a live website that was working fine for a week – nothing has changed and now the recent post section is showing more posts than told to in the back end. I have removed all plugins and the issue still occurs.
I have set the VC Recent Posts to show 3 recent posts and be in a 3/4 + 1/4 (its in the 3/4 section) but its showing 4 articles in a width that fits the 3/4 (must be 30.6666%)
When i change to text view this is what the row is:
[vc_row][vc_column width="3/4"][recent_posts type="post" count="3" orientation="horizontal"][/vc_column][vc_column width="1/4"][button shape="rounded" size="regular" float="none" block="true" info="none" info_place="top" info_trigger="hover" href="http://919freshfm.com.au/shop/"]DONATE TODAY![/button][button shape="rounded" size="regular" float="none" block="true" info="none" info_place="top" info_trigger="hover" href="http://919freshfm.com.au/contact-the-dj"]CONTACT THE DJ[/button][button shape="rounded" size="regular" float="none" block="true" info="none" info_place="top" info_trigger="hover" href="#text-8"]SHARE YOUR STORY[/button][/vc_column][/vc_row]
The site is 919freshfm.com.au and its the recent posts that are directly below the slider – you cant miss them 🙂
August 22, 2014 at 12:05 am #89868Hi there,
Thanks for the information. We might need to look into this further, so 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. Thanks!
September 16, 2014 at 9:48 pm #106189Sorry for such a late reply. I found the issue was that when i have a sticky post that is no longer in the top 3 posts it shows the sticky post AND the top 3 – thus giving 4 posts instead of 3.
September 17, 2014 at 2:31 am #106258Hey there,
Please add the code below in your functions.php.
function x_shortcode_recent_posts_no_sticky( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'type' => '', 'count' => '', 'category' => '', 'offset' => '', 'orientation' => '', 'no_image' => '', 'fade' => '' ), $atts ) ); $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-recent-posts cf ' . esc_attr( $class ) : 'x-recent-posts cf'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $type = ( $type == 'portfolio' ) ? 'x-portfolio' : 'post'; $count = ( $count != '' ) ? $count : 3; $category = ( $category != '' ) ? $category : ''; $category_type = ( $type == 'post' ) ? 'category_name' : 'portfolio-category'; $offset = ( $offset != '' ) ? $offset : 0; $orientation = ( $orientation != '' ) ? ' ' . $orientation : ' horizontal'; $no_image = ( $no_image == 'true' ) ? $no_image : ''; $fade = ( $fade == 'true' ) ? $fade : 'false'; $output = "<div {$id} class=\"{$class}{$orientation}\" {$style} data-fade=\"{$fade}\">"; $q = new WP_Query( array( 'orderby' => 'date', 'post_type' => "{$type}", 'posts_per_page' => "{$count}", 'offset' => "{$offset}", "{$category_type}" => "{$category}", 'post__not_in' => get_option( 'sticky_posts' ) ) ); if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post(); if ( $no_image == 'true' ) { $image_output = ''; $image_output_class = 'no-image'; } else { $image_output = '<div class="x-recent-posts-img">' . get_the_post_thumbnail( get_the_ID(), 'entry-' . x_get_option( 'x_stack', 'integrity' ) . '-cropped', NULL ) . '</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"', '__x__' ), 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_shortcode( 'recent_posts_no_sticky', 'x_shortcode_recent_posts_no_sticky' );
Then, use the shortcode
[recent_posts_no_sticky type="post" category="" count="2" orientation="horizontal"]
It is the same as the
[recent_posts]
shortcode except that it doesn’t allow sticky posts to be displayed.We’ll take note of this issue and might include this bit in a future release.
Hope that helps. 🙂
July 27, 2015 at 3:55 am #341573This reply has been marked as private.July 27, 2015 at 4:10 am #341591I’ve found that if I jump into the code and add post count= “1” it will show properly.
BUT I don’t want to have to do this everytime I make a change.
I have also uninstalled and re-installed Visual Composer the issue remains
I also have the newest version of X Theme 4.0.5
July 27, 2015 at 4:11 am #341593Hi,
It is showing three because you have three recent_posts shortcode with count=1
http://screencast.com/t/kDcdOmpp8
I also created a test page to show that recent posts count is working
Kindly delete it after you check.
Thanks
July 27, 2015 at 4:36 am #341608I apologize it appears you were logged in at the same time I was making adjustments.
The issue is only on the home page, other pages work fine.
I have my recent posts count set to “1”, but it is showing 3 posts on my home page, please check again.
July 27, 2015 at 5:08 am #341637Hi,
This seems to be a bug, when I checked in classic mode > text editor there is no count attribute in the recent posts shortcode.
I will forward this to our web development team as a bug, for the mean time you can add the count manually to your recent posts shortcode in classic mode.
http://screencast.com/t/TxkTOyibv
[recent_posts offset="1" count="1"]
Thanks
July 27, 2015 at 11:33 pm #342454Thanks will do…
July 28, 2015 at 1:52 am #342580You’re welcome.
March 16, 2016 at 9:10 pm #841118I see you guys still haven’t fixed this yet, do you have an ETA on this? Kind of frustrating to have to jump into code when the option is right there and you can select 1, but it just doesn’t work.
March 16, 2016 at 11:15 pm #841274Please update your Visual Composer to the latest X compatible version.
Let us know how it goes.
Thanks!March 17, 2016 at 3:58 pm #842061I’ve already done this, same exact issue remains.
March 17, 2016 at 8:35 pm #842426Hi there,
Yes, somehow, it removes the value when it is equal to the visual composer’s default value. It expects the default value will be supplied automatically by the shortcode, but the internal default value is actually 3. Kind of mismatch since visual composer handles the default value differently.
The workaround is set a default value for count through coding. 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' ); }
Hope this helps.
-
AuthorPosts