Support » Themes and Templates » title and category filter

  • Hello all,

    I have a wordpress page template that is a biography page for a specific presenter… Below the bio, it should list any post that is tagged with that persons name (set as a category on the post.) I thought I had it working, but creating a second presenter, i noticed that it does not work. for reference… Category id 12 is a photo post and Category id 7 means that the post is a video post.

    The tagged posts should separate into 2 lists… one for videos and one for photos that will each share the same tag for speaker.

    Below is the code used for the queries including the sorting. I used a method to where it compares the presenter page title (first and last name of the presenter) and the category for the post… therefore, if the presenter is John Doe… only posts with the category ‘John Doe’ should appear in the lists… but every post appears in the list

    <div id="video_archive">
    	<h4>Featured Videos</h4>
    		<?php
    			query_posts('catagory_name=title_li=&cat=7&showposts=-1');
    			if (have_posts()) {
    			echo '<ul class="list-cat">';
    			while (have_posts()) { the_post();
    		?>
    
    <li><a>"><?php the_title(); ?></a></li>
    		<?php
    			} // end while loop
    			echo '';
    			} // end if
    			wp_reset_query();
    		?>
    </div>
    <div id="photo_archive">
    	<h4>Featured Photos</h4>
    		<?php
    			query_posts('catagory_name=title_li&cat=12&showposts=5');
    			if (have_posts()) {
    				echo '<ul class="list-cat">';
    								while (have_posts()) { the_post();
    		?>
    
    <li><a>"><?php the_title(); ?></a></li>
    		<?php
    			} // end while loop
    			echo '';
    			} // end if
    			wp_reset_query();
    		?>
    </div>

    FYI: it does separate the photos and videos correctly.

    thank you,
    Wes

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello

    You have the word category spelled as category. Quite likely correcting that will solve your problem.

    oops, i mean

    category is spelled as catagory

    I changed the spelling… but still no dice. now, it displays no results.

    Try using the template tag, get_posts(), instead of query_posts.

    get_posts() didnt work, but I saw that it should be $category_name=… rather than just category_name=

    I changed that, and it returned all results that are filed under that type (video or photo posts) but did not filter by the category_name (presenters name.)

    Do you think the problem could lie with the ‘title_li’ part?

    thanks,
    Wes

    Missed that–just use the cat= parameter. You don’t need the category_name.

    still no dice… What I may end up doing is just doing a separate template page for each speaker profile. this will be more reliable I believe.

    I am going to work on that for a bit to get it to work… my only question is: will my filters work with 2 different categories like that? (where I am looking to compare 2 DIFFERENT categories in the same query statement?

    So, I got it to work! thank you for ALL your help. (because I hate it when people don’t post their solutions, the code I used is below.)

    <div id="video_archive">
    	<h4>Featured Videos</h4>
    	<?php $page_title = get_the_title();
    		$page_title = str_replace(" ", "_", $page_title);
    	?>
    	<?php
    		query_posts('category_name=' . $page_title . '&tag=Video+video&showposts=-1$orderby=date');
    		if (have_posts()) {
    			echo '<ul class="list-cat">';
    			while (have_posts()) { the_post();
    	?>
    	<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    	?php
    			} // end while loop
    			echo '</ul>';
    		} // end if
    		wp_reset_query();
    	?>
    </div>
    <div id="photo_archive">
    	<h4>Featured Photos</h4>
    	<?php
    		query_posts('category_name=' . $page_title . '&tag=Gallery+gallery&showposts=-1$orderby=date');
    		if (have_posts()) {
    			echo '<ul class="list-cat">';
    			while (have_posts()) { the_post();
    		?>
    		<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    		<?php
    			} // end while loop
    			echo '</ul>';
    		} // end if
    		wp_reset_query();
    		?>
    </div>
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘title and category filter’ is closed to new replies.