Is there a way to filter by category and year
-
I need to filter the posts by a term from a taxonomy and by a given year.
Since there is no “year” options, I tried to build the right WP query$args = array( 'category_name' => 'cniv0', //(string) - use category slug (NOT name). 'post_type' => 'post', // - a post. 'post_status' => 'publish', // - a published post or page. 'posts_per_page' => -1, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page'=-1 to show all posts. //////Order & Orderby Parameters - Sort retrieved posts. 'order' => 'DESC', //(string) - Designates the ascending or descending order of the 'orderby' parameter. Defaultto 'DESC'. 'orderby' => 'date', //(string) - Sort retrieved posts by parameter. Defaults to 'date'. //////Time Parameters - Show posts associated with a certain time period. 'year' => 2022 ); $the_query = new WP_Query( $args );
and to display the results using get_the_a_z_listing( $the_query );
// The Loop if ( $the_query->have_posts() ) { $a_z_query = get_the_a_z_listing( $the_query ); echo '<div id="' . $a_z_query->the_instance_id() . '" class="az-listing">'; echo ' <div class="az-letters-wrap">'; echo ' <div class="az-letters">' . $a_z_query->the_letters() . '</div>'; echo ' </div>'; if ( $a_z_query->have_letters() ) { echo ' <div class="items-outer">'; echo ' <div class="items-inner">'; while ( $a_z_query->have_letters() ) { $a_z_query->the_letter(); ...
but I got some php error . So, I presume I badly used the plugin interface
Is it possible to transform the WP Query result to a a_z_query, in order to be able to use the different functions the_instance_id(), the_letters(), have_letters(), get_the_letter_items_count(), the_letter_title(), have_items(), the_item(), the_permalink() and the_title() ?
Otherwise is there is any plan to add a year parameter to the shorcode a-z-listing ?
Thanks.
- The topic ‘Is there a way to filter by category and year’ is closed to new replies.