Adding Custom Output Function Made Other Instances Disappear
-
I absolutely LOVE this plugin. But I just ran into a problem I’m not sure how to fix…
I have one set of posts laid out with an image on the left/text on the right. I wanted to customize it to put the title on a line by itself with the excerpt/date on the line below and I found a function (“Display Posts Shortcode plugin: add H2 to title”) that seemed to fit the bill. Like someone else, I changed the H2 to an H3, but other than that, used it as it was. See below:
//---------------------------------------------------------- // Display Posts Shortcode plugin: add H2 to title //---------------------------------------------------------- add_filter( 'display_posts_shortcode_output', 'format_dps_title', 10, 7 ); function format_dps_title( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper ) { // Make Title and H2 $title = ' <h3>'. $title .'</h3>'; // Now let's rebuild the output. $output = '<' . $inner_wrapper . ' class="listing-item">' . $image . $title . $date . $excerpt . '</' . $inner_wrapper . '>'; // Finally we'll return the modified output return $output; }
I called that into my page with this shortcode:
[display-posts category="news-press-releases" include_title="true" include_date="true" date_format="F j, Y" include_excerpt="true" excerpt_length="12" excerpt_more="... [Read More]" excerpt_more_link="true" image_size="menu_images" ignore_sticky_posts="false" wrapper="div" posts_per_page="3"]
It worked brilliantly!
But then, I went to a couple of other pages where I had a different shortcode in use, and all my posts had disappeared. This is one of the shortcodes I used:
[display-posts category="newsletters" include_title="false" include_content="true" wrapper="div" wrapper_class="newsletter_pdf" date_query_before="2017-01-01" date_query_after="2015-12-31" posts_per_page="100"]
and this was another:
[display-posts category="newsletters" include_title="false" include_content="true" wrapper="div" wrapper_class="newsletter_pdf" posts_per_page="1"]
I started backtracking the steps I’d taken to see if I could get them to reappear, and as soon as I deactivated the function above, my other posts came back.
I don’t know if I’ve done something wrong in the function code, or if there is some other conflict. Any ideas?
Thanks in advance!
Terry
https://www.ads-software.com/plugins/display-posts-shortcode/
- The topic ‘Adding Custom Output Function Made Other Instances Disappear’ is closed to new replies.