How to get post by tag_id of the category

wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=3&post_type=post

This is the link when I click on the backend category name:

$args = array( 'post_type' => 'post' , 'orderby' => 'menu_order' , 'order' => 'ASC' , 'posts_per_page' => -1);

By using this I want to display the post for that particular category of tag_id=3. How can I do this?

Read More

This is the full code:

<div class="gallery">

<?php
$i = 1;
$args = array( 'post_type' => 'post' , 'orderby' => 'menu_order' , 'order' => 'ASC' , 'tag_id'=> 3 , 'posts_per_page' => -1);
$wp_query = new WP_Query($args);
$count = $wp_query->found_posts; 
    while ( have_posts() ) : the_post(); 

    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
?>
 <a href="<?php echo $image[0]; ?>" title="<?php the_title();?>"><?php if ( has_post_thumbnail() ) { the_post_thumbnail('thumbnail'); }?></a>

<?php $i++; endwhile;?>  

</div>

Related posts

Leave a Reply

2 comments

  1. you could use WP_Query for display post by tag_id

    try like this:

    $args = array( 'post_type' => 'post' , 'orderby' => 'menu_order' , 'order' => 'ASC' , 'posts_per_page' => -1,'tag_id'=> 3);
    $query = new WP_Query( $args );
    while ( $query->have_posts() ) : $query->the_post();
    
  2. global $wpdb;
            $Qu = $wpdb->get_results("select * from wp_posts where post_title='somthing' and 'post_type' => 'post'");
             $ID = $Qu[0]->ID;
            $Qu1 = $wpdb->get_results("select * from wp_term_relationships where object_id='".$ID."'");
            $ID1 =  $Qu1[0]->term_taxonomy_id;
            $Qu12 = $wpdb->get_results("select * from  wp_term_taxonomy where object_id='".$ID1."'");
            echo $ID1 =     $Qu12[0]->term_id;