WP Query WordPress Post Type with the same Taxonomy name
WP Query WordPress Post Type with the same Taxonomy name
WP Query WordPress Post Type with the same Taxonomy name
Probably you are doing it wrong. When you need do have a one to many relation (one author has many books) taxonomy is not best way. Also, according to WordPress structure, naming a taxonomy and and a post in same way is not a very reliable way. Just for example thinks if two authors are … Read more
Trying to combine multiple WordPress queries
You’re missing the fact that get_posts() (or WP_Query) can take an array() of post types in a singular query. More info on Type Parameters in the Codex. The order will per default be the publishing date. You can then specify it further by adding in stuff like your taxonomy_query, etc. Keep in mind that you … Read more
You can try to store $wp_query in a cookie or in a session variable. global $wp_query; setcookie(‘my_wp_query’, $query_string); or global $wp_query; $_SESSION[‘my_wp_query’] = $query_string; and use that in you ajax function.
You can check if a query has posts with if( $your_query->have_posts() ), and only output the container if it passes that test. $featuredPosts = new WP_Query( array( ‘posts_per_page’ => 2, ‘cat’ => 6, ‘offset’ => 4 ) ); if ( $featuredPosts->have_posts() ) : echo(‘<ul class=”right-hang”>’); while ( $featuredPosts->have_posts() ) : $featuredPosts->the_post(); endwhile; echo ‘</ul>’; endif;
One issue at least: you’ll want to close the loop before outputting your pagination links, or else they’ll be output on every iteration of the loop. But you’ve got paginate_links() before endwhile;. Try this arrangement instead: // open loop if ( have_posts() ) : while ( have_posts() ) : the_post(); // Loop markup // close … Read more
Not sure why this works, where the other query was failing. I’m not sure if it’s a bug that others are experiencing or not. Anytime I included any category “inclusive” arg, it broke my meta_query, but it didn’t seem to if i was “excluding” categories. So,…making an array of all category ids, then unsetting the … Read more
One way to deal with the problem is to use the redirect_canonical filter to cancel the redirect (that happens when the category that the post is assigned to doesn’t match the category slug in the requested post URL) for posts assigned to International (intl) category. /* * Related core file: wp-includes/canonical.php * * NOTE: If … Read more
From the Codex: child_of (integer) Display all categories that are descendants (i.e. children & grandchildren) of the category identified by its ID. There is no default for this parameter. If the parameter is used, the hide_empty parameter is set to false. And… parent (integer) Display only categories that are direct descendants (i.e. children only) of … Read more