Domanda

I'm using the "Pages with category and tag" plugin because my website uses individual long pages as posts. I would like to make a gallery of the past posts (sort of like an archive section), but my theme can filter posts only by categories. I would prefer not to use categories but rather tags, since they are better suited for our content. How can I merge the categories and tags so that my theme can filter these pages using both?

È stato utile?

Soluzione

If you can setup url query parameters and when user navigates to tagfillterPage page with wp_query it should work. https://examples.com/tagfillterPage/?filltertag=tagname

 $querytag = $_GET['filltertag'];
 $args = array(
 'tag' => $querytag
 );
 // Custom query.
 $query = new WP_Query( $args );

 // Check that we have query results.
 if ( $query->have_posts() ) {

 // Start looping over the query results.
 while ( $query->have_posts() ) {

    $query->the_post();

    // Contents of the queried post results go here.}

 }

 // Restore original post data.
 wp_reset_postdata();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top