Recent Posts issues after updating PRO

Just updated to pro ( from pro ) to pro version 1.2.7.

We use customized Recent Posts on all landing pages. After creating a new post - we are seeing a different display- ( see sample home page image ) - wondering of you can point me to and changes in recent post elements - name still .x-recent-posts or such. This happens is single or side by side - this page starts as
[x_recent_posts count=“1” class=“no-border” enable_excerpt=“true” orientation=“horizontal” ]
[x_recent_posts count=“2” class=“no-border” enable_excerpt=“true” orientation=“horizontal” img_left=“true” offset=“1”]

As I mentioned I have a lot of Pro – Child Theme: style.css customization - it appears something has changes in new version - Thanks- Todd

https://wwwpalmspringslife.com - pantheon hosted.

Hi,

To get rid of the space, you can add this in Custom CSS

.x-recent-posts-excerpt .el1.x-section {
    padding:0 !important;
    margin:0 !important;
}

However, I would like to check your custom code for the recent posts.

Can you share to us your code

Thanks

Sure - - See Below - Thanks - Todd

/*Recent Image Left Css */

.jkborder a{padding:0px !important; border: medium none !important;box-shadow:initial !important;border-radius:0px}
.jkimg_left .x-recent-posts-img{padding-bottom:0px;width: 50%;float:left}
.jkimg_left .x-recent-posts-content{width: 50%;float:left;text-align:left;padding:0px 15px}
.jkimg_left .x-recent-posts-content span{font-size: 14px !important;}
.jkimg_left .h-recent-posts { font-size: 18px !important; font-weight: 600 !important; padding-bottom: 5px; padding-top: 10px;}
.jkborder{border-top:1px solid #000 !important;}

/* Image Left End */

/*Recent Single Image Left Css */

.recentP1 .x-recent-posts-content{text-align:left}

/* Recent Single Image Left End */

.x-site .x-container.offset {
margin-top: 2 !important;
}

/Recent Posts - remove p spacing - line height
.x-text p:empty,
.x-text br {
display: none;
}
/

.x-text .x-recent-posts {
margin-bottom: 8px;
line-height:1.0;
}

.x-recent-posts .x-recent-posts-date {
display: none;
}

Hi Todd,

Have you done some PHP customization for the recent post? The space above the except of the first item seem to be caused by a blank section that might be added through PHP.

Although the code that @paul.r provided should get rid of the blank space, you might still want to check the PHP code you have added that is adding the extra div.

Hope this helps.

Thanks Jade - Paul - the code did not work - I don;t see any custom php injecting that blank section - id el1 x-section something new with V2 elements?

Todd

Hey Todd,

The issue must be in your custom recent post element. I know you have customized it because the default recent post element does not have an excerpt. I have tested it in the page in the secure note.

Please provide the code of your custom recent post shortcode or give us ftp access so that we can access it right away and correct the issue.

Thank you.

Thanks RwuMel - see below.

Todd

// Recent Posts (new code in Cornerstone)
// =============================================================================

function x_shortcode_recent_posts_v2code( $atts ) {
extract( shortcode_atts( array(
‘id’ => ‘’,
‘class’ => ‘’,
‘style’ => ‘’,
‘type’ => ‘post’,
‘count’ => ‘’,
‘category’ => ‘’,
‘offset’ => ‘’,
‘orientation’ => ‘’,
‘no_image’ => ‘’,
‘fade’ => ‘’,
‘sponsor_content’ => ‘’,
‘img_left’ => ‘’,
‘enable_excerpt’ => ‘’
), $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_image = ( $no_image == ‘true’ ) ? $no_image : ‘’;
$fade = ( $fade == ‘true’ ) ? $fade : ‘false’;
$img_left = ( $img_left == ‘true’ ) ? $img_left : ‘false’;
$enable_excerpt = ( $enable_excerpt == ‘true’ ) ? true:false;

$js_params = array(
‘fade’ => ( $fade == ‘true’ )
);

$data = cs_generate_data_attributes( ‘recent_posts’, $js_params );

if($img_left == ‘true’){
$leftClass = ’ jkborder ';
$class = ‘x-recent-posts cf’;
}
if($count == ‘1’) {
$countC = ’ recentP1 ';
}
$output = “<div {$id} class=”{$class}{$orientation}{$leftClass}{$countC}" {$style} {$data} data-fade="{$fade}" >";

$q = new WP_Query( array(
  'orderby'          => 'date',
  'post_type'        => "{$type}",
  'posts_per_page'   => "{$count}",
  'offset'           => "{$offset}",
  "{$category_type}" => "{$category}"
) );

if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post();
$content_excerpt = get_the_excerpt();
$pcontent = get_the_content(); 
$arr = explode('[cs_text]', $pcontent);
$textA =  $arr[1];
if($textA == '') {
	$textA =  get_the_content(); 
}
 
if($sponsor_content == 'true') {
  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 jkrecentImg"' . $bg_image . '></div>';
    $image_output_class = 'with-image';
  }
 $output .= '<a id="jkrecentDiv" class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"' ), 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 jkrecentContent">'
                   . '<h3 class="h-recent-posts">' . get_the_title() . '</h3>'
		. '<span class="x-recent-posts-date">' . get_the_date() . ', by ' . get_the_author() . '</span>'
                   . ( $enable_excerpt ? '<span class="x-recent-posts-excerpt">' . wp_trim_words( $textA, $num_words = 10, $more = null ) . '</span>' : '' )
                 . '</div>'
               . '</div>'
             . '</article>'
           . '</a>';
} else {
  if ( $no_image == 'true' ) {
	  
    $image_output       = '';
    $image_output_class = 'no-image';
	 $output .= '<a class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"' ), 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() . ', by ' . get_the_author() .  '</span>'
                   . ( $enable_excerpt ? '<span class="x-recent-posts-excerpt">' . wp_trim_words( $textA, $num_words = 10, $more = null ) . '</span>' : '' )
                 . '</div>'
               . '</div>'
             . '</article>'
           . '</a>';
  } else if($img_left == 'true') {
	  
	$image              = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
    $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="jkimg_left x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"' ), the_title_attribute( 'echo=0' ) ) ) . '">'
             . '<article id="post-' . get_the_ID() . '" class="' . implode( ' ', get_post_class() ) . '">'
               . '<div class="entry-wrap2">'
                 . '<div class="x-recent-posts-img"><img src='.$image[0].'></div>'
                 . '<div class="x-recent-posts-content">'
                   . '<h3 class="h-recent-posts">' . get_the_title() . '</h3>'
                   . ( $enable_excerpt ? '<span class="x-recent-posts-excerpt">' . wp_trim_words( $textA, $num_words = 10, $more = null ) . '</span>' : '' )
                 . '</div>'
               . '</div>'
             . '</article>'
           . '</a>';
	  
  } else {
	 
    $image              = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
    $bg_image           = ( $image[0] != '' ) ? ' style="background-image: url(' . $image[0] . ');"' : '';
    $image_output       = '<div class="x-recent-posts-img jkimg"' . $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"' ), the_title_attribute( 'echo=0' ) ) ) . '">'
             . '<article id="post-' . get_the_ID() . '" class="' . implode( ' ', get_post_class() ) . '">'
               . '<div class="entry-wrap2">'
                 . $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() . ', by ' . get_the_author() .  '</span>'
                   . ( $enable_excerpt ? '<span class="x-recent-posts-excerpt">' . wp_trim_words( $textA, $num_words = 10, $more = null ) . '</span>' : '' )
                 . '</div>'
               . '</div>'
             . '</article>'
           . '</a>';
  }
 
}
endwhile; endif; wp_reset_postdata();

$output .= ‘’;

return $output;
}

add_action(‘wp_head’, ‘change_recent_posts_to_v2’);

function change_recent_posts_to_v2() {
remove_shortcode( ‘x_recent_posts’ );
add_shortcode( ‘x_recent_posts’, ‘x_shortcode_recent_posts_v2code’ );
}

Hi there,

All are correct, and I don’t see any space anymore. It doesn’t look like as your provided screenshot. Or maybe you have fixed it?

Plus, can you change this line

wp_trim_words( $textA, $num_words = 10, $more = null )

to this

wp_trim_words( get_the_excerpt(), 10, '' )

Thanks!

Prefect thanks- Todd

You’re always welcome Todd!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.