Tuesday, August 30, 2022
HomeWordPress Developmentwp question - Forestall WordPress loop from displaying related put up titles

wp question – Forestall WordPress loop from displaying related put up titles


How can I stop WordPress loop from displaying related put up titles?

eg.

The primary put up title is: Regular content material

But when the array $posts_ids has a put up with the title: Now we have some regular content material, my code repeats twice this put up contained in the output content material…

I am utilizing this snippet to have a second loop inside my put up. Let me clarify:

I’ve a customized area right here I retailer all of the posts ID’s that I prefer to name on this loop

$posts_ids = get_post_meta($post_id, 'posts_ids', true);

Then I construct the args

$arrayIds = explode(',', $posts_ids);
$args = array('post_type' => 'put up','post__in' => $arrayIds, 'ignore_sticky_posts' => 1);

$temp = $custom_query;
$custom_query= null;
$custom_query = new WP_Query( $args );

Then I begin the second loop on the put up after the the_content

if($custom_query->have_posts()) : whereas ($custom_query->have_posts()) : $custom_query->the_post();
        // My customized HTML right here          
    endwhile;

    wp_reset_postdata(); 
    
    else: 
    
    endif;

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments