Tag Info

New answers tagged

0

Your inner loop overwrites the contents of $post, so any later template tags use the values of whatever it last contained. "But I used wp_reset_postdata()!" you say? What that function does is try to restore $post from $wp_query->post. It's meant to restore the main query after secondary queries. You have two secondary queries here, so that method fails. ...


1

It is quite easy to achieve this. Your answer is usort() FEW NOTES: Before we code, just a few notes Requires PHP5.4+ due to the use of the short array syntax ([]). If you have an older version, you should really upgrade as older versions are a real security threat as all older versions prior to PHP 5.4 has been EOL'ed I will comment the code as I go ...


0

By default, WP doesn't sort by taxonomy/tag. A probable solution is doing 3 separate get_posts calls, one for each tag, then using array_merge to combine the results into 1 array.


0

tag__in is not listed as a valid orderby value in the codex. I'd suggest grabbing more posts than you need, and ordering them within your PHP.


0

in case you cant get the above to work make sure you add post_type eg $args = array( 'post_type' => 'pt_case_study', 'post__in' => array(2417, 2112, 784) ); $posts = get_posts($args);


0

@Milo's answer worked perfectly (see comment above). if (in_array($post->ID, $do_not_duplicate)) continue; meant that duplicate posts were still being counted in the loop, though not being displayed. To fix, remove this line, and exclude duplicate posts from the query with this argument: 'post__not_in' => $do_not_duplicate. Thank you @Milo for your ...


0

try to use a new WP_Query, when you use get_posts you're using the main WP_Query this has hooks that other plugins can use to alter the query. something else i saw is that you're using include key which is not valid $my_query = new WP_Query( array( 'post__in' => array( 1633, 1634, 1635 ), 'post_status' => 'any', 'post_type' => ...


0

As you are looking at post IDs, you should be using meta_value_num instead of meta_value as your key. This will indicate to WP how to handle the comparison.



Top 50 recent answers are included