Custom query before default query in single-posttype.php
-
Beloved WordPressers,
In single-posttype.php, I’m doing a custom query before the regular
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
.[please mark any code in your post – see https://codex.www.ads-software.com/Forum_Welcome#Posting_Code ]
Before the custom query, I clone the wp_query:
$temp = clone $wp_query;
After the custom query, I set it back and erase postdata:
<?php $my_query = null; $my_query = clone $temp; ?> <?php wp_reset_postdata(); ?>
But the detail post that should be showing shows all the posts that the first query (custom query) finds.
What am I doing wrong?
Thanks a lot for your time, much obliged!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Custom query before default query in single-posttype.php’ is closed to new replies.