Permalinks for custom taxonomy stopped to work

Sometimes a plugin changes WordPress’ internal rewrite rules during an update, an installation or deactivation. If the plugin’s update happens to run after your taxonomy registration it may just wipe out the custom rules for the taxonomy. To inspect the currently active rewrite rules use the plugin Monkeyman Rewrite Analyzer. See this answer for details. … Read more

Custom Taxonomy Permalinks Redirection

What is the best way to allow http://www.domain.com/newtype/newtax-term/post-name/ to load, without redirecting? You have to add a custom rewrite rule to make this work. Otherwise WordPress doesn’t understand the newtax-term part of your permalink structure and redirects you to the URL which it does understand, which is %post_type%/%post_slug%. If you want to understand how WordPress … Read more

$wpdb query a post type within a specific taxonomy term while ordering posts by custom meta value?

You have a typo in orderby, and meta_value_num is only used as an orderby value, try this: $args = array( ‘post_type’ => ‘event’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘locations’, ‘field’ => ‘id’, ‘terms’ => $location // location term id ) ), ‘meta_key’ => ‘event_date’, // this meta field stores event date in yymmdd format … Read more

$wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies

Do a tax-query and then count the result. No need for a custom query with dozens of JOINS. $posts = new WP_Query( array( ‘post_type’ => ‘MYPOSTTYPE’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘TAX_1’, ‘field’ => ‘slug’, ‘terms’ => array( ‘TERM_TAX_1’ ), ‘operator’ => ‘IN’ ), array( // etc. ) ), ‘post_status’ => ‘publish’ ); prinft( … Read more

Sidebar links for different pages

Register a new sidebar by pasting this into your theme’s functions.php file: register_sidebars( ‘id’ => ‘patientedu’ ); Create a file called sidebar-patientedu.php and paste the following into it: <?php if (is_active_sidebar(‘patientedu’)) : ?> <div id=”sidebar”> <h2>PatientEdu Sidebar</h2> <?php dynamic_sidebar(‘patientedu’); ?> </div> <?php endif; ?> Then paste this whereever you want your sidebar to show up: … Read more

How do I Use Multiple Loops with WP_Query?

As Toscho mentionned above, you didn’t close your if and while. When in doubt, indent your codes to avoid confusion. $my_query = new WP_Query( $args ); if ($my_query->have_posts()) : while($my_query->have_posts()) : $my_query->the_post(); endwhile; endif; wp_reset_postdata(); /* The 2nd Query (without global var) */ $query2 = new WP_Query( $args2 ); // The 2nd Loop if ($query2->have_posts()) … Read more