How to determ a custom post type url?

You need to register a custom taxonomy for you custom post type. For example: add_action(‘init’, ‘register_book_taxonomy’); function register_book_taxonomy() { $labels = array( ‘name’ => ‘Book Categories’, ‘singular_name’ => ‘Book Category’, ‘search_items’ => ‘Search Book Categories’, ‘all_items’ => ‘All Book Categories’, ‘parent_item’ => ‘Parent Book Category’, ‘parent_item_colon’ => ‘Parent Book Category:’, ‘edit_item’ => ‘Edit Book Category’, … Read more

Trying to create a shortcode that displays taxonomy terms in a dropdown

This fixed my issue, hopefully it can help someone else. <?php add_shortcode(‘city_dropdown’, ‘city_taxonomy_dropdown’); function city_taxonomy_dropdown( $atts ) { // Attributes $atts = shortcode_atts(array( ‘hide_empty’ => ‘1’, // or ‘0’ ‘show_count’ => ‘0’, // or ‘0’ ‘orderby’ => ‘name’, // or ‘order’ ‘taxonomy’ => ‘city’, ), $atts, ‘city_dropdown’); ob_start(); ?> <select class=”<?php echo esc_attr($atts[‘taxonomy’]); ?>” name=”<?php … Read more

wp_get_post_terms not working as expected

I misunderstood what you were trying to do before. I thought you wanted to list the terms associated with one particular post – the one you are on. Whoops! Try this instead: $terms = get_terms(‘fruit_category’); if(!empty($terms)){ echo “<ul>”; foreach ( $terms as $term ) { echo ‘<li><a href=”‘.get_term_link($term->slug, ‘fruit_categories’).'”>’. $term->name . “</a></li>”; } echo “</ul>”; … Read more

Add taxonomy or category slug to custom post types URL

You would do it by assigning the taxonomies when registering the post type: ‘taxonomies’ => [ ‘taxonomy1’, ‘taxonomy2′, ..etc ], https://developer.wordpress.org/reference/functions/register_post_type/#taxonomies https://developer.wordpress.org/reference/functions/register_post_type/#taxonomies-2 You can also use register_taxonomy_for_object_type to do this if you want a function call. You still need to register the taxonomies though or this won’t work. Note that this won’t change your CPT’s … Read more

Different templates for parent and children Taxonomy

The {$type}_template_hierarchy filter can be used to add templates to the list of files to check for each request: Filters the list of template filenames that are searched for when retrieving a template to use. With this filter, you can do something like below: add to theme’s functions.php or an mu-plugin (untested): add_filter( ‘taxonomy_template_hierarchy’, static … Read more

Two related taxonomies. how to filter terms in second taxonomy depending on selected term in first taxonomy on Post edit page?

My approach would be: Hide city edition metabox, by setting public to false. I would override how metabox for country should render by using meta_box_cb parameter. You should provide callback for the function that will do the render. In this function, you first render the field for country, and then on choose you make an … Read more

Searching in categories AND custom fields

Adding the tax_query parameter to the $args array with the proper arguments will check for the category as well (untested): $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 15, ‘paged’ => $paged, ‘meta_query’ => array( array( ‘key’ => ‘meta_easyfatt_libero_1’, ‘value’ => ‘Men’, ‘compare’ => ‘LIKE’, ), ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)