General WordPress Related

(Difference between revisions)
Jump to: navigation, search
(How to show posts from only a certain category/categories or exclude posts from a certain category/categories)
m (How to show posts from only a certain category/categories or exclude posts from a certain category/categories)
Line 29: Line 29:
 
# http://stylizedweb.com/2008/08/13/query_posts-pagination-problem/
 
# http://stylizedweb.com/2008/08/13/query_posts-pagination-problem/
  
== '''Requirement''': Only posts from a certain category should appear on Posts page ==
+
Category ID can be seen by going to Posts -> Categories, placing the mouse cursor on desired category and observing the number at the end of URL in the browser status bar.
 +
 
 +
== Only posts from a certain category should appear on Posts page ==
  
 
'''How to''': Edit your theme's index.php.
 
'''How to''': Edit your theme's index.php.
Line 54: Line 56:
 
Category ID can be seen by going to Posts -> Categories, placing the mouse cursor on desired category and observing the number at the end of URL in the browser status bar.
 
Category ID can be seen by going to Posts -> Categories, placing the mouse cursor on desired category and observing the number at the end of URL in the browser status bar.
  
== '''Requirement''': Posts from a certain category should be excluded from Posts page ==
+
== Posts from a certain category should be excluded from Posts page ==
  
 
'''How to''': Edit your theme's index.php.
 
'''How to''': Edit your theme's index.php.
Line 76: Line 78:
  
 
In the above, change "24" to the ID of category from which posts should NOT be shown. Posts from all other categories will appear.
 
In the above, change "24" to the ID of category from which posts should NOT be shown. Posts from all other categories will appear.
 
Category ID can be seen by going to Posts -> Categories, placing the mouse cursor on desired category and observing the number at the end of URL in the browser status bar.
 
  
 
=Third entry=
 
=Third entry=
  
 
=Fourth entry=
 
=Fourth entry=

Revision as of 12:51, February 6, 2011

Contents

Author page Not Found

Problem: Clicking on the author name link (Ex.: http://www.leonardowood.com/author/Leonardo%20Wood/) in posts shows Page Not Found.

Solution:

The author link is supposed to be http://www.leonardowood.com/author/leonardo-wood/

Add the following to your theme's functions.php, reload your site twice.

global $wpdb;
 $wpdb->query("UPDATE `{$wpdb->users}` SET `user_nicename`='leonardo-wood' WHERE `ID`='1'");

In the above replace "leonardo-wood" with your user nicename (User name in small case with hypens between spaces).

The above also assumes that ID of user in question is 1. This can be checked via phpMyAdmin in wp_users table.

After ensuring that this has been fixed, remove the above code from functions.php.

Source: http://ithemes.com/forum/index.php?/topic/9701-author-link-produces-404-page-not-found-error/#p45383

How to show posts from only a certain category/categories or exclude posts from a certain category/categories

References:

  1. http://codex.wordpress.org/Function_Reference/query_posts
  2. http://stylizedweb.com/2008/08/13/query_posts-pagination-problem/

Category ID can be seen by going to Posts -> Categories, placing the mouse cursor on desired category and observing the number at the end of URL in the browser status bar.

Only posts from a certain category should appear on Posts page

How to: Edit your theme's index.php.

Ex.: Change

	<?php if ( have_posts() ) : ?>
		<?php while ( have_posts() ) : // The Loop ?>
			<?php the_post(); ?>

to

	<?php if ( have_posts() ) : ?>
	<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=1&paged=$paged"); ?>
		<?php while ( have_posts() ) : // The Loop ?>
			<?php the_post(); ?>

In the above, change "1" to the ID of category from which posts should be shown. Posts from all other categories won't appear.

Category ID can be seen by going to Posts -> Categories, placing the mouse cursor on desired category and observing the number at the end of URL in the browser status bar.

Posts from a certain category should be excluded from Posts page

How to: Edit your theme's index.php.

Ex.: Change

	<?php if ( have_posts() ) : ?>
		<?php while ( have_posts() ) : // The Loop ?>
			<?php the_post(); ?>

to

	<?php if ( have_posts() ) : ?>
	<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=-24&paged=$paged"); ?>
		<?php while ( have_posts() ) : // The Loop ?>
			<?php the_post(); ?>

In the above, change "24" to the ID of category from which posts should NOT be shown. Posts from all other categories will appear.

Third entry

Fourth entry

Personal tools
Namespaces
Variants
Actions
iThemes Codex
Codex Navigation
Toolbox