Site logo

Archived topic

change query for single if post has category

1 reply · Started by Tesco on August 30, 2022

Viewing posts 1–2 of 2

How can I change the query for single post if that post has a specific category?

These are the args that I need:

$postIds = get_post_meta($post->ID, 'posts_ids', true);
$arrayIds = explode(',', $postIds);
$args = array('post_type' => 'post','post__in' => $arrayIds, 'ignore_sticky_posts' => 1);

Then the template should call something like this:
<?php if(have_posts()): while(have_posts()): the_post(); ?>

So that I can build my custom HTML here

This archived topic is closed to new replies.