How to show taxonomy terms from wordpress database?

Solution One: get_terms() – Retrieve the terms in a given taxonomy or list of taxonomies. You can fully inject any customizations to the query before it is sent, as well as control the output with a filter. The ‘get_terms’ filter will be called when the cache has the term and will pass the found term … Read more

Shortcode to return single custom post based on post taxonomy

From your supplied info, it’s not all very clear to me. But as far as I’ve understood your problem, here’s my approach. Assuming we have the following shortcode that the user has put inside a normal post’s content and that this shortcode will pull information from your custom post type case_studies: [casestudy study_type=”mountain”] So firstly, … Read more

How to get if child category of this category is empty?

You’re going to need to loop over the $re_child_terms array. According the docs get_term_children returns an array of term_ids so you will need to loop over the ids, get the terms and save them into a new array if they’re not empty. $re_child_term_ids = get_term_children( $term->term_id, ‘category’ ); $re_child_terms = array(); foreach ( $re_child_terms_ids as … Read more

Loop through custom taxanomy in post and display custom fields from posts

You are going to need set up a new WP_Query in your content-*.php with the correct parameters in order to send it into a loop. <?php $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘recipes’,. ‘field’ => ‘slug’, ‘terms’ => ‘dessert’ ))); $your_posts = new WP_Query( $args ); ?> You can add any other … Read more

How to get attached image to taxonomy..?

If your going to reference the uploads directory use https://developer.wordpress.org/reference/functions/wp_upload_dir/ <?php $upload_dir = wp_upload_dir(); // Array of key => value pairs /* $upload_dir now contains something like the following (if successful) Array ( [path] => C:\path\to\wordpress\wp-content\uploads\2010\05 [url] => http://example.com/wp-content/uploads/2010/05 [subdir] => /2010/05 [basedir] => C:\path\to\wordpress\wp-content\uploads [baseurl] => http://example.com/wp-content/uploads [error] => ) // Descriptions [path] – … Read more

Changing CPT slug and taxonomy already registered in parent theme

WordPress 4.5 introduced the functions unregister_post_type() and unregister_taxonomy(). You could deregister your post type respectively taxonomy and register them again with your custom settings. The post type is still named portfolio. You could rename it, but you would probably have to check your template files for references. add_action(‘init’, ‘wpse_247924_overwrite_theme_post_types’, 1000); function wpse_247924_overwrite_theme_post_types() { unregister_post_type( ‘portfolio’ … Read more

List Top 5 taxonomy terms based on number of post

Here I’ve written a SQL query based function for you. You can use it to also for getting the top taxonomy terms based on post date range. Here it is- function the_dramatist_get_taxonomy_based_on_date_range_and_post_count( $args = array() ) { global $wpdb; $default_args = array( ‘taxonomy’ => ‘category’, ‘start_date’ => date(‘Y-m-d’), ‘end_date’ => date(‘Y-m-d’, strtotime(‘tomorrow’)), ); $args = … Read more

WordPress database products structure

To add product, you need to add an entry in posts table, with post_type=”product”, post_title=”product_name”, post_excerpt=”product_description”. This will give you the post ID. with the post ID, you will be able to add meta datas in the post_metas table._product_type, _visibility, _price, _sale_price…. use terms tables to add category related to the product You can see … Read more

WP 4.7 in_category change?

I’ve found the issue. I’ve been running a filter on list_terms_exclusions specifically to remove all children of “Uncategorized” from appearing on the public website. add_filter(‘list_terms_exclusions’, ‘my_list_terms_exclusions’,10,2); However, using in_category() still returned matches on those categories, which was exactly what I wanted. I needed to hide those categories from appearing in category listings, but I still … Read more