WordPress Category Page Hacks
posted October 6th 2004 at 1219 EDT in All
The following two hacks will increase the usability of WordPress category pages by giving an index of posts instead of a paged overview, and by sorting posts by title instead of post date.
Index
To change your category pages to an index of titles instead of including excerpts from posts, add the following to your index.php page around the normal if ($posts) : foreach ($posts as $post) loop.
<?php
$temp_category = single_cat_title
('',
false);
if (!
empty($temp_category)){
// give index
?>
<h1><?php single_cat_title
(); ?></h1>
<p><?php
echo(category_description
(the_category_ID
(false))); ?></p>
<?php if ($posts) :
foreach ($posts as $post) : start_wp
();
?>
<a href=
"<?php the_permalink() ?>"><?php the_title
(); ?></a><br>
<?php endforeach;
else:
?>
<p><?php _e
('Sorry, no posts matched your criteria.'); ?></p>
<?php endif;
?>
<?php
}else{ // give details or single post
?>
...... code
for normal post overview
<?php
}
?>
Sort
Insert the following code in wp-blog-header.php at line 345 to order the category pages by title instead of date. This is a simple way to increase usability as users who are looking for content have no clue when information was posted.
if ($whichcat)
{
$orderby = 'title';
$order = 'ASC';
}
10 years, 2 months ago
[...] finds: Elastic Dog’s Faking Multiple Templates in WordPress Jehiah Czebotar’s WordPress Category Page Hacks WP Support Forum: Archive Titles by Category [...]
5 years, 4 months ago
Thank you for the sort code, it’s made me very happy.
5 years, 3 months ago
You say to “add the following to your index.php page around the normal if ($posts) : foreach ($posts as $post) loop.”
I’m new to wordpress and I dont really understand code so I’m confused as to what you mean by “around” In other words, WHERE EXACTLY should this code be placed?
5 years, 3 months ago
sorry.
“around” not as in near or close to, but as in wrapping around. Leave the whole
if ($posts)section in the location I described above as..... code for normal post overview5 years, 3 months ago
Hey, thanks, you’re fast but I still dont get it..
If you have a moment, here is the section of the index.php code.. could you point out where your code would go? Thanks again, I really, really appreciate you taking the time to respond.
5 years, 3 months ago
Dangit it didnt post correctly.
Oh well.
I apologize for my ignorance. Code is a foreign language to me and I need ultra precise guidance.
thanks again
5 years, 3 months ago
Ok, so an easier way to explain it is replace what you posted (the
<div id="content">block)with everything in this fileYour welcome; we all have to start with code somewhere =)
5 years, 3 months ago
When I use it my page doesn’t display, I get a message that says: Parse error: parse error, unexpected ‘}’on line 47.
I don’t even know which line is 47.
Thanks again for your help, I just can’t deal with this anymore tonite. It took me a little time to get the hang of editing CSS… all trial and error but it makes a lot more sense than this code. My brain hurts.
Again, thank you very much.
5 years, 3 months ago
doh! I need to work on my copy and paste skills.. Should work now;
5 years, 2 months ago
This is awesome! I’m using it for my writing site :)
5 years, 1 month ago
Works like a charm. Thanks!
4 years, 11 months ago
Wonderful, I’ve been looking for a way to alphabetize my categories forever. Thanks!
4 years, 11 months ago
Any way to get the sort hack to work in wordpress 1.5?
4 years, 10 months ago
I finally figured out how to hack the categories to display in alphabetical order for wordpress 1.5. You modify the wp-includes/classes.php file. Go to line 462, and add in this:
4 years, 10 months ago
Thanks Eric! Needed that final bit of help to get the list to sort. Now I need to figure out how to get more than 10 items on a list. am pretty sure it is a simple fix – just hope it doesn’t change it for all pages.
Another cool addition would be if the date of the post showed up in parenthesis after the post title.
4 years, 6 months ago
Hi Jehiah,
Quick Q: Have you ever seen/written a category hack where for each category it would use a completely different theme? (Not a template file… a complete theme). Kinda like the style switcher plugin, but rather than the web visitor running the show, it would be their choice of the category view that would choose the theme. Your knowledge and expertise is invited to respond :)
Thanks,
j
4 years, 2 months ago
To get more than your default limit of posts on a list, simply add this code right before the script starts…
4 years, 2 months ago
Sorry, hopefully this will show the code…
4 years, 2 months ago
Well, if you want the code you can get it here, I can’t get it to display in teh comments…
http://wordpress.org/support/topic/23333
4 years, 1 month ago
[...] update on sorting wordpress categories in wordpress 1.5 [...]
4 years, 1 month ago
This may be an obvious question, but what should I replace “…… code for normal post overview” with?
4 years, 1 month ago
[...] WordPress Category Page Hacks The following two hacks will increase the usability of WordPress category pages by giving an index of posts instead of a paged overview, and by sorting posts by title instead of post date. [...]
3 years, 9 months ago
Well, it took me a while to wrap my mind around how to do this… but at last it is implemented and it’s wonderful. Many thanks for publishing this hack.
3 years, 8 months ago
I took this idea and made a plugin.
So now, if you just want to sort posts in category view by title rather than by date, then here’s a plugin to quickly do just that:
mikesmullin.com/2006/05/23/wordpress-plugin-sort-category-posts-by-title/
3 years, 7 months ago
Hey all…
Like many im new to Wordpress and Code…
What i really need for my site is a sort of Alphabetic Index so if u need to know about a curtain thing and you know it starts with an ..you just press A and all articles that starts with an A comes up..
Is that in anyway possible ???
Thanks alot…
3 years, 6 months ago
[...] I took the ideas from the Category Page Hack and put them in Category.php in my template directory. I think it makes it a lot cleaner and allowed me to more easily tailor the category pages to display as I want them to without making index.php any more confusing than it already is. [...]
3 years, 4 months ago
You can also use the following code in the index.php or in the sidebar wherever your categories are.
The optioncount is to show how many post within the particular categories.
3 years, 4 months ago
You can also use the following code in the index.php or in the sidebar wherever your categories are.
<?php wp_list_cats(’sort_column=name&optioncount=1&hierarchical=0′); ?>
The optioncount is to show how many post within the particular categories.
3 years, 3 months ago
nice post, thanks
2 years, 9 months ago
Thanks for the post, dude. I’ve always thought the Wordpress category system was “unideal” at best.
Thanks again,
Brandon Drury
2 years, 4 months ago
[...] It is hard to create a good navigation structure with posts with default settings (you can hack the code to make it a little easier) See category page hacks [...]
1 year, 11 months ago
[...] 41. WordPress Category Page Hacks (Source: Jehiah) [...]
1 year, 11 months ago
[...] 41. WordPress Category Page Hacks (Source: Jehiah) [...]
1 year, 10 months ago
[...] 8 ) Category Page Hacks- These 2 hacks will increase the usability of WordPress category pages by giving an index of posts instead of a paged overview, and by sorting posts by title instead of post date. [...]
1 year, 10 months ago
[...] 1) When Your WordPress Theme Keeps Reverting To Default- Have you ever been working on your WordPress blog’s design, when you refresh the page only to find that it’s decided to revert to the default theme? 2) How to place a login form in the sidebar- Want to get your users log in through the front page, Small Potato’s tutorial will show you how.3) When Your WordPress Theme Keeps Reverting To Default- Have you ever been working on your WordPress blog’s design, when you refresh the page only to find that it’s decided to revert to the default theme? 4) Adding Recent Comments To Your WordPress Theme- Displays recent comments in the sidebar without the need for a plug-in: 5) Creating your home.php quite easily on WordPress- Two easy ways to use if you just want a static front page on your blog. 6) Even Simpler WordPress Contact Form- A simple solution for all your contact form needs. All comments left with this form are displayed in your WordPress administration panel. 7)WP Date Image Hack- Using dynamic images to replace the date entries of your blog post. 8 ) Category Page Hacks- These 2 hacks will increase the usability of WordPress category pages by giving an index of posts instead of a paged overview, and by sorting posts by title instead of post date. 9)Creating a “dynamic sticky”- When we need to have certain articles ’stay at the top’ longer than others. 10)Show Category Images- How to add some simple PHP code to your WordPress template and make linked images appear instead of text for your categories in posts. 11) Displaying WordPress Entries on static pages- A simple solution to include the date, headline, and excerpt of the latest entry from your Blog into your website static pages. 12) Ajax Commenting- How to make your commenting system submit comment without reloading the whole page.13) Opening Links in New Windows- This hack is for those who want to open links in a new browser window and don’t want to type out target=”_blank” every single time. [...]
1 year, 9 months ago
[...] WordPress Category Page Hacks Uncategorized [...]
1 year, 9 months ago
[...] 8 ) Category Page Hacks- These 2 hacks will increase the usability of WordPress category pages by giving an index of posts instead of a paged overview, and by sorting posts by title instead of post date. [...]
1 year, 8 months ago
[...] WordPress Category Page Hacks [...]
1 year, 7 months ago
[...] 41. Ajustes para página de Categorias (Fonte: Jehiah) [...]
1 year, 6 months ago
[...] Category Page Hacks [...]
1 year, 5 months ago
[...] 41. WordPress Category Page Hacks ( Sursa: Jehiah) [...]
1 year, 4 months ago
[...] WordPress Category Page Hacks [...]
1 year, 2 months ago
[...] 1) When Your WordPress Theme Keeps Reverting To Default- 你有没有碰到过当你刷新页面的时候,你的博客主题恢复到了Wordpress的默认主题? (帕兰注: 通常我碰到这样的情况是,如果在FTP上传主题文件的时候刷新博客的页面,就一定会恢复成默认模板,不知道其它人是否也是这样?) 2) How to place a login form in the sidebar- 如何放置登录表单到侧边栏 4) Adding Recent Comments To Your WordPress Theme- 在你的侧边栏显示最新留言列表,而不需要任何插件 5) Creating your home.php quite easily on WordPress- 两个简单的方法,为你的Wordpress首页创建静态页面 6) Even Simpler WordPress Contact Form- 一个简单的解决方法,用来整合你所有需要的联系表单。所有的留言将显示在 WordPress后台管理界面的一份表单中。 7)WP Date Image Hack- 使用动态的图像替换你博客日志的日期. 8 ) Category Page Hacks- 这是两个hacks技巧,用来增加 WordPress 分类页面的可用性,主要用来创建一个文章索引替换掉原先的页面概况,并且可以通过文章标题和发布日期来进行排序浏览. 9)Creating a “dynamic sticky”- 教你如何创建一个动态的置顶效果. 10)Show Category Images- 如何通过添加一些简单的PHP代码到你的 WordPress 模板,从而实现分现的图片链接显示,替换原本的文本分类。 11) Displaying WordPress Entries on static pages-一个简单的方法创建静态的Wordpress日志页面,包括日期,标题和摘要。 12) Ajax Commenting- 如何让你的留言系统达到当提交留言时不需要重新载入整页的Ajax效果。13) Opening Links in New Windows- 这个hack技巧是为那些想让自己的页面在新窗口中打开而不需要每次都使用target=”_blank”的朋友准备的。 [...]
1 year ago
[...] 41. WordPress Category Page Hacks (Source: Jehiah) [...]
12 months ago
[...] 83.WordPress Theme Hacks. 84. No More CSS Hacks. 85. Create a Dynamic Sticky. 86. Styling Individual Posts Using the_ID. 87. Show Category Images. 88. Separate WordPress Comments and Trackbacks. 89. Customize your WordPress Login. 90. Date Image Hack. 91. How to place a login form in the sidebar. 100. WP: KeyBoard Shortcuts. 101. Making Better Use of Your Error “404? Page. 102. Customize Your 404 Page. 103. WordPress accessibility hacks. 104. Reset your Lost WordPress Administrator Password. 105. The Definitive Guide to Semantic Web Markup for Blogs. 106. Do-It-Yourself WordPress Hover Menu (Pop-Up). 107. How to Protect CSS Mods for ANY WordPress Theme. 108. WP Contact Manager. 109. Wordpress and the custom fields, a overlooked feature. 110. DiggProof your Wordpress. 111. WordPress Ajax Commenting revisited. 112. Widgetizing Themes. (Source: Automattic.) 113. Cloaking to Stop Scraping. 114. Server load button for blogs. 115. Giving each WordPress post a thumbnail, and display the thumbnail on the home page. 116. How to create overlapping tabs. 117. How to Optimize Your WordPress Title. 118. Blocking Your WordPress Categories and Archives From Google. 119. Adding An Author Page To Your WordPress Blog. 120. Make a Mobile Friendly Version of your Blog with Google Reader.121. How to Use Wordpress as a Membership Directory. 122. How to Format Images for Feed Readers. 123. Add Del.icio.us Daily Blog Posting To Your WordPress Blog. 124. Huge Compilation of WordPress Code. 125. 4 Simple ways to Speed up Wordpress. 126. WordPress Date Button. (Source: WP Designer. 127. Wicked WordPress Archives in One Easy Step! . 128. Make Yourself Available to Readers with a Contact Form. 129. Wordpress as a CMS – Content Management System. 130. Installing Xampp and WordPress (Locally). 131. WordPress Category Page Hacks. 132. 3 WordPress Hacks For SE-Friendly Blog Archives. 133. Opening Links in New Windows. 134. WordPress Thumbnail Size Limit Hack. 135. Restore your Wordpress Database. 136. Validating Wordpress. 137. Backing Up Wordpress. 138. Getting your feet wet inWP. 139. Importing Content from another blog. [...]
11 months, 3 weeks ago
[...] 83.WordPress Theme Hacks. 84. No More CSS Hacks. 85. Create a Dynamic Sticky. 86. Styling Individual Posts Using the_ID. 87. Show Category Images. 88. Separate WordPress Comments and Trackbacks. 89. Customize your WordPress Login. 90. Date Image Hack. 91. How to place a login form in the sidebar. 100. WP: KeyBoard Shortcuts. 101. Making Better Use of Your Error “404? Page. 102. Customize Your 404 Page. 103. WordPress accessibility hacks. 104. Reset your Lost WordPress Administrator Password. 105. The Definitive Guide to Semantic Web Markup for Blogs. 106. Do-It-Yourself WordPress Hover Menu (Pop-Up). 107. How to Protect CSS Mods for ANY WordPress Theme. 108. WP Contact Manager. 109. Wordpress and the custom fields, a overlooked feature. 110. DiggProof your Wordpress. 111. WordPress Ajax Commenting revisited. 112. Widgetizing Themes. (Source: Automattic.) 113. Cloaking to Stop Scraping. 114. Server load button for blogs. 115. Giving each WordPress post a thumbnail, and display the thumbnail on the home page. 116. How to create overlapping tabs. 117. How to Optimize Your WordPress Title. 118. Blocking Your WordPress Categories and Archives From Google. 119. Adding An Author Page To Your WordPress Blog. 120. Make a Mobile Friendly Version of your Blog with Google Reader.121. How to Use Wordpress as a Membership Directory. 122. How to Format Images for Feed Readers. 123. Add Del.icio.us Daily Blog Posting To Your WordPress Blog. 124. Huge Compilation of WordPress Code. 125. 4 Simple ways to Speed up Wordpress. 126. WordPress Date Button. (Source: WP Designer. 127. Wicked WordPress Archives in One Easy Step! . 128. Make Yourself Available to Readers with a Contact Form. 129. Wordpress as a CMS – Content Management System. 130. Installing Xampp and WordPress (Locally). 131. WordPress Category Page Hacks. 132. 3 WordPress Hacks For SE-Friendly Blog Archives. 133. Opening Links in New Windows. 134. WordPress Thumbnail Size Limit Hack. 135. Restore your Wordpress Database. 136. Validating Wordpress. 137. Backing Up Wordpress. 138. Getting your feet wet inWP. 139. Importing Content from another blog. [...]
11 months, 3 weeks ago
[...] 41. WordPress Category Page Hacks (Source: Jehiah) [...]
10 months, 1 week ago
[...] 94. WordPress Category Page Hacks [...]
10 months, 1 week ago
[...] 94. WordPress Category Page Hacks [...]
9 months, 2 weeks ago
[...] 113. WordPress Category Page Hacks [...]
9 months, 1 week ago
[...] 这里是一些 WordPress 高级指导 83.WordPress Theme Hacks 84. No More CSS Hacks 85. Create a Dynamic Sticky 86. Styling Individual Posts Using the_ID 87. Show Category Images 88. Separate WordPress Comments and Trackbacks 89. Customize your WordPress Login 90. Date Image Hack 91. How to place a login form in the sidebar 100. WP: KeyBoard Shortcuts 101. Making Better Use of Your Error “404? Page 102. Customize Your 404 Page 103. WordPress accessibility hacks 104. Reset your Lost WordPress Administrator Password 105. The Definitive Guide to Semantic Web Markup for Blogs 106. Do-It-Yourself WordPress Hover Menu (Pop-Up) 107. How to Protect CSS Mods for ANY WordPress Theme 108. WP Contact Manager 109. Wordpress and the custom fields, a overlooked feature 110. DiggProof your Wordpress 111. WordPress Ajax Commenting revisited 112. Widgetizing Themes (Source: Automattic) 113. Cloaking to Stop Scraping 114. Server load button for blogs 115. Giving each WordPress post a thumbnail, and display the thumbnail on the home page 116. How to create overlapping tabs 117. How to Optimize Your WordPress Title 118. Blocking Your WordPress Categories and Archives From Google 119. Adding An Author Page To Your WordPress Blog 120. Make a Mobile Friendly Version of your Blog with Google Reader 121. How to Use Wordpress as a Membership Directory 122. How to Format Images for Feed Readers 123. Add Del.icio.us Daily Blog Posting To Your WordPress Blog 124. Huge Compilation of WordPress Code 125. 4 Simple ways to Speed up Wordpress 126. WordPress Date Button (Source: WP Designer) 127. Wicked WordPress Archives in One Easy Step! 128. Make Yourself Available to Readers with a Contact Form 129. Wordpress as a CMS – Content Management System 130. Installing Xampp and WordPress (Locally) 131. WordPress Category Page Hacks 132. 3 WordPress Hacks For SE-Friendly Blog Archives 133. Opening Links in New Windows 134. WordPress Thumbnail Size Limit Hack 135. Restore your Wordpress Database 136. Validating Wordpress 137. Backing Up Wordpress 138. Getting your feet wet in WP 139. Importing Content from another blog [...]
8 months, 3 weeks ago
[...] 94. WordPress Category Page Hacks [...]
8 months, 1 week ago
Great plugin. But I cannot find the if ($whichcat)
{
$orderby = ‘title’;
$order = ‘ASC’;
}
part in the wp-blog-header.php file. I guess it was for an older version of wordpress.
7 months, 3 weeks ago
I got the posts to view on the page. Do you know how to limit the number of the posts on page and make the page navigate to older posts?
7 months, 3 weeks ago
[...] 83.WordPress Theme Hacks. 84. No More CSS Hacks. 85. Create a Dynamic Sticky. 86. Styling Individual Posts Using the_ID. 87. Show Category Images. 88. Separate WordPress Comments and Trackbacks. 89. Customize your WordPress Login. 90. Date Image Hack. 91. How to place a login form in the sidebar. 100. WP: KeyBoard Shortcuts. 101. Making Better Use of Your Error “404? Page. 102. Customize Your 404 Page. 103. WordPress accessibility hacks. 104. Reset your Lost WordPress Administrator Password. 105. The Definitive Guide to Semantic Web Markup for Blogs. 106. Do-It-Yourself WordPress Hover Menu (Pop-Up). 107. How to Protect CSS Mods for ANY WordPress Theme. 108. WP Contact Manager. 109. Wordpress and the custom fields, a overlooked feature. 110. DiggProof your Wordpress. 111. WordPress Ajax Commenting revisited. 112. Widgetizing Themes. (Source: Automattic.) 113. Cloaking to Stop Scraping. 114. Server load button for blogs. 115. Giving each WordPress post a thumbnail, and display the thumbnail on the home page. 116. How to create overlapping tabs. 117. How to Optimize Your WordPress Title. 118. Blocking Your WordPress Categories and Archives From Google. 119. Adding An Author Page To Your WordPress Blog. 120. Make a Mobile Friendly Version of your Blog with Google Reader.121. How to Use Wordpress as a Membership Directory. 122. How to Format Images for Feed Readers. 123. Add Del.icio.us Daily Blog Posting To Your WordPress Blog. 124. Huge Compilation of WordPress Code. 125. 4 Simple ways to Speed up Wordpress. 126. WordPress Date Button. (Source: WP Designer. 127. Wicked WordPress Archives in One Easy Step! . 128. Make Yourself Available to Readers with a Contact Form. 129. Wordpress as a CMS – Content Management System. 130. Installing Xampp and WordPress (Locally). 131. WordPress Category Page Hacks. 132. 3 WordPress Hacks For SE-Friendly Blog Archives. 133. Opening Links in New Windows. 134. WordPress Thumbnail Size Limit Hack. 135. Restore your Wordpress Database. 136. Validating Wordpress. 137. Backing Up Wordpress. 138. Getting your feet wet inWP. 139. Importing Content from another blog. [...]
7 months, 1 week ago
[...] WordPress Category Page Hacks [...]
7 months, 1 week ago
[...] WordPress Category Page Hacks [...]
6 months, 3 weeks ago
[...] WordPress Category Page Hacks [...]
6 months ago
[...] 83.WordPress Theme Hacks. 84. No More CSS Hacks. 85. Create a Dynamic Sticky. 86. Styling Individual Posts Using the_ID. 87. Show Category Images. 88. Separate WordPress Comments and Trackbacks. 89. Customize your WordPress Login. 90. Date Image Hack. 91. How to place a login form in the sidebar. 100. WP: KeyBoard Shortcuts. 101. Making Better Use of Your Error “404? Page. 102. Customize Your 404 Page. 103. WordPress accessibility hacks. 104. Reset your Lost WordPress Administrator Password. 105. The Definitive Guide to Semantic Web Markup for Blogs. 106. Do-It-Yourself WordPress Hover Menu (Pop-Up). 107. How to Protect CSS Mods for ANY WordPress Theme. 108. WP Contact Manager. 109. Wordpress and the custom fields, a overlooked feature. 110. DiggProof your Wordpress. 111. WordPress Ajax Commenting revisited. 112. Widgetizing Themes. (Source: Automattic.) 113. Cloaking to Stop Scraping. 114. Server load button for blogs. 115. Giving each WordPress post a thumbnail, and display the thumbnail on the home page. 116. How to create overlapping tabs. 117. How to Optimize Your WordPress Title. 118. Blocking Your WordPress Categories and Archives From Google. 119. Adding An Author Page To Your WordPress Blog. 120. Make a Mobile Friendly Version of your Blog with Google Reader.121. How to Use Wordpress as a Membership Directory. 122. How to Format Images for Feed Readers. 123. Add Del.icio.us Daily Blog Posting To Your WordPress Blog. 124. Huge Compilation of WordPress Code. 125. 4 Simple ways to Speed up Wordpress. 126. WordPress Date Button. (Source: WP Designer. 127. Wicked WordPress Archives in One Easy Step! . 128. Make Yourself Available to Readers with a Contact Form. 129. Wordpress as a CMS – Content Management System. 130. Installing Xampp and WordPress (Locally). 131. WordPress Category Page Hacks. 132. 3 WordPress Hacks For SE-Friendly Blog Archives. 133. Opening Links in New Windows. 134. WordPress Thumbnail Size Limit Hack. 135. Restore your Wordpress Database. 136. Validating Wordpress. 137. Backing Up Wordpress. 138. Getting your feet wet inWP. 139. Importing Content from another blog. [...]
6 months ago
[...] 41. WordPress Category Page Hacks (Source: Jehiah) [...]
5 months, 1 week ago
[...] 113. WordPress Category Page Hacks [...]
5 months ago
[...] WordPress Category Page Hacks [...]
1 month, 3 weeks ago
[...] Category Page Hacks [...]