Tagged: x
-
AuthorPosts
-
January 27, 2017 at 12:03 pm #1348007
Kerri SParticipantSorry – this did work but I didn’t see a way to delete this. The information below worked but the exerpt didn’t show up while in Cornerstone.
______ Original message_____
I’m looking to have added to my php file as per instructions from 2014. I’m only getting the image with title and date. I’d like to have the image, date and exerpt. This request seems to be ongoing for a long time. Any easy solutions in an update? 🙂
Here’s what I did.
URL: http://kovapartners.com/newsitedev8173/
WP version: WordPress 4.5.2 running X – Child Theme theme.
Cornerstone: version 1.2.4Used short code: [x_recent_posts type=”post” count=”4″ enable_excerpt=”true”
orientation=”horizontal”]Added this to child theme in path /wp-content/themes/x-child/functions.php
/ =============================================================================
// Add Excerpt to Recent Posts -> [x_recent_posts]
// =============================================================================function x_shortcode_recent_posts_excerpt( $atts ) {
extract( shortcode_atts( array(
‘id’ => ”,
‘class’ => ”,
‘style’ => ”,
‘type’ => ‘post’,
‘count’ => ”,
‘category’ => ”,
‘offset’ => ”,
‘orientation’ => ”,
‘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_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’ => true
) );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’;
}endwhile; endif; wp_reset_postdata();
$output .= ‘</div>’;
return $output;
}add_action(‘wp_head’, ‘update_x_recent_posts_to_v2’);
function update_x_recent_posts_to_v2() {
remove_shortcode( ‘x_recent_posts’ );
add_shortcode( ‘x_recent_posts’, ‘x_shortcode_recent_posts_excerpt’ );
}January 27, 2017 at 9:14 pm #1348526
DarshanaModeratorGlad you were able to figure it out 🙂
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1348007 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
