Custom taxonomy link automatically removing query string and re-directing

WordPress uses the redirect_canonical function in order to ensure that URLs are properly following the current permalink structure: https://codex.wordpress.org/Function_Reference/redirect_canonical The function is hooked to automatically run on the template_redirect filter. In order to remove it, you need to add the following snippet to your theme or plugin: remove_filter( ‘template_redirect’, ‘redirect_canonical’ ); Keep in mind that … Read more

Loop to display ONLY custom taxonomy parent information [closed]

I believe this has already been answered perfectly in How can I get only parent terms?. The solution is to set ‘parent’ => 0 when querying terms with get_terms() or WP_Term_Query. The example from that question looked like this: $myterms = get_terms( array( ‘taxonomy’ => ‘taxonomy_name’, ‘parent’ => 0 ) ); You can easily loop … Read more

Query custom post types & Taxonomies and list them in a table on a page

You can use term_query in WP_Query: $args = array( ‘post_type’ => ‘all_parks’, ‘posts_per_page’ => -1, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘all_park_categories’, ‘field’ => ‘slug’, ‘terms’ => ‘national_parks’, ), ), ); $all_parks = new WP_Query( $args ); Query all posts with all categories and sort by term or create … Read more

wp_dropdown_categories – how to save in widget?

You didn’t add the dropdown/select name attribute, that’s why it’s not working as expected. Please try updating your $dropdown_args, here’s the updated arguments – $dropdown_args = array( ‘taxonomy’ => ‘cs_categories’, ‘id’ => $this->get_field_id( ‘cs-category’ ), ‘name’ => $this->get_field_name( ‘cs-category’ ), // Added this line ‘show_option_none’ => __( ‘Select category’, ‘text-domain’ ), ‘hide_empty’ => true, ‘hierarchical’ … Read more

Hide custom post type from search based on custom taxonomy

register_post_type() has a argument that you can set to specify which post types you want searched, thus excluded the undesired ones. This is the simplest method, just one line: ‘exclude_from_search’ = true, Alternative to that, you can hook into the search query itself via pre_get_posts and then modify the search, specifying which post types you’re … Read more