Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 26th Dec 2011, 10:17 PM   #1
Active Warrior
 
drewhowell21's Avatar
 
Join Date: 2011
Location: North Carolina
Posts: 54
Thanks: 6
Thanked 9 Times in 7 Posts
Default
List Post Titles For Current Category
Share on: 
fb share twitter share gplus share more share

I'm creating a template and seem to be stuck while I'm creating my category template. Currently I have all my posts listed when you click on a category. I'm wanting to include a list of post titles at the top for quick navigation. What would be the correct loop for this? Or do I need to create individual templates for each category and go the query_posts( 'cat=3' ); and echo out the_title(); route?
drewhowell21 is offline  
Unread 26th Dec 2011, 10:22 PM   #2
HyperActive Warrior
War Room Member
 
ussher's Avatar
 
Join Date: 2010
Location: Tokyo
Posts: 314
Thanks: 27
Thanked 43 Times in 42 Posts
Default
Re: List Post Titles For Current Category
Share on: 
fb share twitter share gplus share more share

real hard to understand your question.

is this php?
is this wordpress?
something else?

"Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."
- jamroom.net
Download Jamroom free: Download
ussher is offline  
Unread 26th Dec 2011, 10:31 PM   #3
Active Warrior
 
drewhowell21's Avatar
 
Join Date: 2011
Location: North Carolina
Posts: 54
Thanks: 6
Thanked 9 Times in 7 Posts
Default
Re: List Post Titles For Current Category
Share on: 
fb share twitter share gplus share more share

Originally Posted by ussher View Post

real hard to understand your question.

is this php?
is this wordpress?
something else?
Sorry about that. I've been staring at Notepad++ too long.

I'm working on creating a Wordpress Template. I'm in the process of creating a category page template. Currently, I have the category page displaying all post content for all posts (title, thumbnail, excerpt, etc). I'm wanting to create a list of only post titles ( the_title(); ) for the current category page. I've only found solutions where you have to query categories by id to echo out posts. I'm looking for a solution that goes off the current category.
drewhowell21 is offline  
Unread 26th Dec 2011, 10:55 PM   #4
HyperActive Warrior
War Room Member
 
ussher's Avatar
 
Join Date: 2010
Location: Tokyo
Posts: 314
Thanks: 27
Thanked 43 Times in 42 Posts
Default
Re: List Post Titles For Current Category
Share on: 
fb share twitter share gplus share more share

this any use?
WordPress › Support ยป How do I display post titles from current category and highlight active post

"Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."
- jamroom.net
Download Jamroom free: Download
ussher is offline  
The Following User Says Thank You to ussher For This Useful Post:
Unread 27th Dec 2011, 09:55 AM   #5
VIP Warrior
War Room Member
 
SteveJohnson's Avatar
 
Join Date: 2007
Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
Default
Re: List Post Titles For Current Category
Share on: 
fb share twitter share gplus share more share

Originally Posted by drewhowell21 View Post

Sorry about that. I've been staring at Notepad++ too long.

I'm working on creating a Wordpress Template. I'm in the process of creating a category page template. Currently, I have the category page displaying all post content for all posts (title, thumbnail, excerpt, etc). I'm wanting to create a list of only post titles ( the_title(); ) for the current category page. I've only found solutions where you have to query categories by id to echo out posts. I'm looking for a solution that goes off the current category.
If I understand you correctly, you just want an extra list of the post titles that appear later on the page?

If that's right, it's terribly easy - you have the array of post objects available anywhere within the template, so you can just use multiple loops by hitting the rewind button (this code has no HTML, you'll have to add in what you need):
Code:
<?php
## first loop, for titles
if ( have_posts() ): while ( have_posts() ) : the_post();
the_title();
endwhile; endif;
## 'rewind' to make the loop available again
rewind_posts();

## do other template stuff here

## now, another loop
if ( have_posts() ): while ( have_posts() ) : the_post();
the_permalink(); the_content();
endwhile; endif;
?>

The 2nd Amendment, 1789 - The Original Homeland Security.

Gun control means never having to say, "I missed you."
SteveJohnson is offline  
The Following User Says Thank You to SteveJohnson For This Useful Post:
Unread 27th Dec 2011, 10:56 AM   #6
Active Warrior
 
drewhowell21's Avatar
 
Join Date: 2011
Location: North Carolina
Posts: 54
Thanks: 6
Thanked 9 Times in 7 Posts
Default
Re: List Post Titles For Current Category
Share on: 
fb share twitter share gplus share more share

Originally Posted by SteveJohnson View Post

If I understand you correctly, you just want an extra list of the post titles that appear later on the page?

If that's right, it's terribly easy - you have the array of post objects available anywhere within the template, so you can just use multiple loops by hitting the rewind button (this code has no HTML, you'll have to add in what you need):
Code:
<?php
## first loop, for titles
if ( have_posts() ): while ( have_posts() ) : the_post();
the_title();
endwhile; endif;
## 'rewind' to make the loop available again
rewind_posts();

## do other template stuff here

## now, another loop
if ( have_posts() ): while ( have_posts() ) : the_post();
the_permalink(); the_content();
endwhile; endif;
?>
I'm pretty sure this is what I need. The part I'm still not understanding is how to only list posts from the current category page I'm on. I know I can target individual categories by their id, but that would involve creating separate templates for each category. Am I overlooking something that's extremely obvious? I'm currently at work, so I'm not able to "play" around with it at the moment.
drewhowell21 is offline  
Unread 27th Dec 2011, 01:50 PM   #7
Shantanu
 
shantanu's Avatar
 
Join Date: 2011
Location: New Delhi
Posts: 263
Thanks: 4
Thanked 16 Times in 16 Posts
Default
Re: List Post Titles For Current Category
Share on: 
fb share twitter share gplus share more share

This is basically a PHP code guys.....coz if wordpress will give these types of errors then it must be in SQL Server form.
shantanu is offline  
Unread 27th Dec 2011, 01:51 PM   #8
Active Warrior
 
drewhowell21's Avatar
 
Join Date: 2011
Location: North Carolina
Posts: 54
Thanks: 6
Thanked 9 Times in 7 Posts
Default
Re: List Post Titles For Current Category
Share on: 
fb share twitter share gplus share more share

I was able to get my categories listed by running a second loop. Thanks a lot, man!

PHP Code:
<div class="postlist">
                <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                    
                        <ul>
                            <li class="posttable"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a>    </li>    
                        </ul>    
                        
                <?php endwhile; else: ?>
                <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
                <?php endif; ?>
</div>
How could I get that to display in multiple columns? "column-count:3;" doesn't seem to work.
drewhowell21 is offline  
Closed Thread


Bookmarks

Tags
category, current, list, post, titles


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:54 AM.