• Hi all, I am trying to filter posts by category on a custom archive / template page. My template page currently has a custom query which displays posts from four specific categories. Then I have a select (dropdown) form, that in theory, filters the posts by a chosen one of the four categories.

    <form id="category-select" class="category-select" action="<?php echo esc_url( home_url( '/business-ready/news-updates-new/' ) ); ?>" method="get">
    <li>
    		<?php
    		$args = array(
    			'show_option_none' => __( 'Category' ),
    			'show_count'       => 0,
    			'orderby'          => 'name',
    			'echo'             => 0,
    			'class'            => 'search-select',
    		);
    		?>
    		<?php $select  = wp_dropdown_categories( $args ); ?>
    		<?php echo $select; ?>
    	</li>
    	<li><input type="submit" value="GO!" /></li>
    </form>

    This select form works on the main blog archive page, but not my custom template page. Any ideas? Am I missing something? All and any help is appreciated, thanks in advance!

Viewing 1 replies (of 1 total)
  • Thread Starter aronjeney

    (@aronjeney)

    Do I have to create an action with “pre_get_posts”? How do I go about that in order to filter my custom archive template page?

    Again, any and all help is appreciated as always!

Viewing 1 replies (of 1 total)
  • The topic ‘How to filter posts by category on archive / template page?’ is closed to new replies.