Custom Shortcode Function error: Listing Posts on a Page
-
Firstly, I am not a developer I am a graphic designer. Help please.
The Code Snippets function lists the specified postsbycategory on the page where the shortcode is inserted, initially no comments nor the response box displayed because comments are disabled on the page.
However, after recent updates to WP and plugins now it displays the comments forms and responses on the last post in the results displayed on the page.
How can I exclude the response box and fields and all the submitted comments from being displayed at the bottom of the page the shortcode is used on?
Many thanks in advance for your assistance.
function faq_postsbycategory() { // the query $the_query = new WP_Query( array( 'category_name' => 'faq', 'posts_per_page' => 10, 'order' => 'ASC', 'orderby' => 'link' ) ); // The Loop if ( $the_query->have_posts() ) { $string .= '<div class="postsbycategory widget_recent_entries">'; while ( $the_query->have_posts() ) { $the_query->the_post(); if ( has_post_thumbnail() ) { $string .= '<p>'; $string .= '<b><a href="' . get_the_permalink() . '"rel="bookmark">' . get_the_post_thumbnail($post_id, array( 200, 100) ) . get_the_title() . '</a></b><br><h7>Posted: ' . get_the_date() . '</h7><br>' . get_the_excerpt() . '</p>'; } else { // if no featured image is found ADD EXCERPT CODING // $string .= '<p><a href="' . get_the_permalink() .'" rel="bookmark">' . get_the_title() . '</a><br><h7>Posted: ' . get_the_date() . '</h7><br>' . get_the_excerpt() . '</p>'; } } } else { // no posts found } $string .= '</div>'; return $string; /* Restore original Post Data */ wp_reset_postdata(); } // Add a shortcode add_shortcode('faq-posts', 'faq_postsbycategory');
The page I need help with: [log in to see the link]
- The topic ‘Custom Shortcode Function error: Listing Posts on a Page’ is closed to new replies.