• Here is the sample code used to search pages that have a certain tag. Created as a function. Just call the function, passing in the name of the tag slug name.

    function get_nav_item( $navItem ){
    
        $pages = new WP_Query(array(
            'post_type' => 'page',
            'tag' => $navItem
        ));
    
        if ($pages->have_posts()):
            while($pages->have_posts()):$pages->the_post();
                echo the_title();
            endwhile;
        endif;
    }
  • The topic ‘SOLVED – Searching pages by Tag’ is closed to new replies.