WordPress.org

Forums

Display Posts from Custom Post Type and Taxonomy (3 posts)

  1. Haris Nadeem
    Member
    Posted 2 years ago #

    Hi,

    Can someone please help me with this?

    I have a custom post type 'kernels'. I also have a custom taxonomy called 'devices' which is attached to that custom post type 'kernels' and the regular Posts.

    In my taxonomy-devices.php, I want to display posts from 'kernels' and Posts separately.

    Any help would be appreciated, please! Thanks!

  2. Haris Nadeem
    Member
    Posted 2 years ago #

    I tried using the following code:

    <?php
    $args = array(
    'post_type' => 'kernels',
    'tax_query' => array(
    array(
    'taxonomy' => 'devices',
    'field' => 'slug',
    'terms' => 'abc'
    )
    )
    );
    $kernels = new WP_Query( $args );
    if( $kernels->have_posts() ) {
    while( $kernels->have_posts() ) {
    $kernels->the_post();
    ?>
    <h1>" rel="bookmark"><?php the_title(); ?></h1>
    <div class="posttext"><?php the_excerpt(); ?></div><div style="clear:both;"></div>
    <?php
    }
    }
    else {
    echo 'Oh ohm no products!';
    }
    ?>

    But it started showing all my posts that are attached to the term 'abc' on every term page. I want it to only show posts from the specific term I have opened.

  3. Haris Nadeem
    Member
    Posted 2 years ago #

    Anyone, please?

Topic Closed

This topic has been closed to new replies.

About this Topic