WordPress.org

Forums

Taxonomy.php how to show post only in current taxonomy with wp_query (1 post)

  1. jhonb
    Member
    Posted 1 year ago #

    Hi guys,

    Having troubles to get my taxonomy.php working good.

    I use a taxonomy.php to list all my posts in a specific category but it shows every post I have in all categories.

    Here is my code:

    <ul class="scenes cf">
    
        <?php
    
        $args1 = array(
          'post_type'=>'artistes',
          'orderby' => 'menu_order',
          'order' => 'ASC',
          'meta_query' => array(
                array(
                    'key' => 'date_de_lartiste',
                    'value' => '',
                    'compare' => 'LIKE'
                ),
                array(
                    'key' => 'heure_de_lartiste',
                    'value' => '',
                    'compare' => 'LIKE'
                )
            )
        );
    
        add_filter('posts_orderby','orderbyreplace');
        $loop = new WP_Query( $args1 );
        remove_filter('posts_orderby','orderbyreplace');
        ?>
        <?php $todaysDate = date('Y/m/d'); ?>
        <?php if ($loop->have_posts() ) { while ( $loop->have_posts() ) { $loop->the_post(); ?>
        <?php
        	$date = get_field('date_de_lartiste');
        	$newDate = date("d/m/Y", strtotime($date));
        ?>
        <li>
        	<div class="info">
        		<?php the_post_thumbnail( 'artists_list' )?>
        		<p><?php the_title(); ?></p>
        		<p class="music_style"><?php echo $newDate ?> - <?php the_field('heure_de_lartiste'); ?></p>
        	</div>
        	<a href="<?php the_permalink(); ?>" class="read_more"><?php _e('Read More'); ?></a>
        </li>
        <?php
        	}
        		} else {
        		    ?>
        		    <li class="cf">
        				<p>No posts</p>
        			</li>
        		    <?php
        	}
        		/* Restore original Post Data */
        		wp_reset_postdata();
        ?>
    </ul>

    Does anyone may help me to figure it out? How to display only the post in the current taxonomy?

    Thanks a lot,

    Jhon

Topic Closed

This topic has been closed to new replies.

About this Topic