How To Get Post By Taxonomy In WordPress

Taxonomies are basically a way of grouping data in WordPress.

How To Get Post By Taxonomy In WordPress

How To Get Post By Taxonomy In WordPress

Taxonomy are basically a way of grouping data in WordPress. The most common default taxonomy used in WordPress are when grouping posts as either ‘categories’ or ‘tags’ and these are named and recorded in the WordPress database as ‘category’ and ‘post_tag’ respectively. Specific categories or tags are called terms.

You can see this image for get post-

taxonomy21 taxonomy211

Follow this code-

<?php 
    $post_type = "news";
  $taxonomy = "latest";
  
      $temp = $wp_query;  // re-sets query
        $wp_query = null;   // re-sets query
    $args = array( 'post_type' => 'news', 'order'=>'ASC', 'posts_per_page' => 6, 'tax_query' => array(array('taxonomy' => 'latest', 'field' => 'id', 'terms' => $term_id))); 
    $wp_query = new WP_Query();
    $wp_query->query( $args );
    while ($wp_query->have_posts()) : $wp_query->the_post(); ?>  
    
         <?php the_title(); ?>
         <?php the_content(); ?>
  
    <?php
      endwhile;
      ?>

 

Tags:

2 comments

  1. HindIndia
    Reply

    Really amazing article …. very nice … Thanks for sharing this!! 🙂 🙂

    • admin
      Reply

      Thank You so much 🙂

Leave a Reply

most readable posts

Filter Posts By Category WordPress

If you have lots of posts in your WordPress site, you have probably used the Category and/or Tag filter at the top of the post. These filter are great because they very quickly allow you to limit the kind of posts that are displayed, and let you find the one(s) you are looking for with […]

Read more
Get Custom Post Type With WP_Query In WordPress

In this post I’ll give you an in-depth look into how WP_Query works – let’s get started! This series on WP_Query, you’ll learn how to use WP_Query to query for posts, pages and custom post types. You can query for specific posts and pages or you can run a query to return posts of one […]

Read more
How To Get Post By Taxonomy In WordPress

Taxonomy are basically a way of grouping data in WordPress. The most common default taxonomy used in WordPress are when grouping posts as either ‘categories’ or ‘tags’ and these are named and recorded in the WordPress database as ‘category’ and ‘post_tag’ respectively. Specific categories or tags are called terms. You can see this image for […]

Read more

About Me

We are glad to see you here… If you are visiting for the first time, then, we hope you’ll stay with us in Touch. Codinglead is all about sincere blogging and spreading some basic and some advanced knowledge to you All. As you can see that here that codinglead.com is working on many different categories and concepts (check out in the Menu).

Our Expertise

  • We are providing the resources of the following technologies:
  • Web Development
  • Web Programming
  • PHP/MySQL
  • Know more.