wp query – I made a navigation menu, but it doesn’t work

Question

i want click the a link, browse by tag, or by random, or by reverse order, or by most comments, or by most views, to show the posts, how to do it?

  <?php $tags = get_tags(array(
            'orderby'                => 'count',
            'order'                  => 'DESC',
            'hide_empty'             => true,
        ));
        foreach ($tags as $tag) {
            echo '<li><a href="' . get_tag_link( $tag->term_id ) . '">' . $tag->name . '</a></li>';
        } // this can select the tag list


        $args = array(
            'orderby' => (isset($_GET['by']) ? $_GET['by'] : 'date'),
            'order' => (isset($_GET['dir']) ? $_GET['dir'] : 'DESC'),
        ); 
        query_posts( $args );// this can select flashback or random
        echo '<li><a href="?dir=ASC">ASC</a></li>';
        echo '<li><a href="?by=rand">RAND</a></li>'; ?> 

 <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

In the above code, the content will not change after clicking TAG, but after commenting out query_posts, the tags will be normal. How to make them all work normally?

0
metalbug 1 month 2021-08-16T21:14:03-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse