Prevent pre_get_posts filter on specific post type

Improve your conditional to include a check for post type being queried. It can be done via WP_Query::get method So, where you have if ( !is_admin() ){ $query->set( ‘meta_key’, ‘_ct_selectbox_52f65ae267764’ ); $query->set( ‘meta_value’, $city ); return; } replace with if ( ! is_admin() && in_array ( $query->get(‘post_type’), array(‘event’,’venue’) ) ) { $query->set( ‘meta_key’, ‘_ct_selectbox_52f65ae267764’ ); … Read more

get term archive url / link

Use get_term_link e.g. to print out a list of actors terms linking to the archives: $terms = get_terms(‘actors’); echo ‘<ul>’; foreach ($terms as $term) { echo ‘<li><a href=”‘.get_term_link($term).'”>’.$term->name.'</a></li>’; } echo ‘</ul>’; However! If what you really mean is the equivilant of the custom post type archive, that lists all the posts of that type, but … Read more

Permalink Structure for Multiple Post Type Archives by Taxonomy

Here is part of the code from one of my projects to setup a similar structure for permalinks (same base slug for both the post type and the taxonomy archives), please note the values of ‘has_archive’ and ‘rewrite’ parameters of both the post type and the taxonomy: add_action( ‘init’, ‘register_my_post_types’ ); function register_my_post_types() { register_post_type( … Read more

Display a query with multiple post types and same relationship on a single page

You’re setting the post meta as a_clients, but the query is looking for a_client. update_post_meta($post_id, ‘a_clients’, $new); ‘key’ => ‘a_client’ Those need to be the same. Since updating the query means you won’t have to go updating posts again, I suggest updating the key of the meta_query to a_clients.

WPML with WP_Query serving up all 3 languages [closed]

My solution was to register the custom post types on the site where I’m calling it from, then in WPML’s settings set them to translate. This is in WPML -> Translation Management -> Multilingual Content Setup, down at the bottom. I assume it works by tricking WP into using that site’s rewrite/translate rules when it … Read more

Filtering a custom post type by custom taxonomy in archive template

Let say you have “book” post type and “genre” taxonomy. And you want to get books with genre of “scifi”. You can pass the parameter in the url using: ?taxonomy=genre&term=scifi Then you can get those parameter using get_query_var(‘taxonomy’) and get_query_var(‘term’) and add them to the WP_Query arguments. $taxonomy = get_query_var(‘taxonomy’); $term = get_query_var(‘term’); $args = … Read more