What is the PHP code to limit post categories on home page?
-
I’ve had to take over a WordPress site someone else has created. It’s a bit weird – the home page is largely controlled by the header.php!
Anyway the header.php page currently has the following code that shows titles for the latest 7 posts.
Trouble is I want to limit the list to only certain categories.
Lets say the full range of categories are:
Category: Apples (ID: 1)
Category: Oranges (ID: 2)
Category: Pears (ID: 3)Below is the current code that shows titles of all categories.
How can I make it so that the homepage only shows titles for Apples and Oranges?<?php @mysql_pconnect( $dbhost, $dbuser, $dbpassword, true ); $result = mysql_query("SELECT * FROM wp_posts WHERE post_type='post' AND post_status='publish' ORDER BY post_date DESC LIMIT 0,7"); while($row = mysql_fetch_array($result)) { echo '<li><a href="'.$root_site.''.$row['post_name'].'" title="">'.$row['post_title'].'</a></li>'; } ?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘What is the PHP code to limit post categories on home page?’ is closed to new replies.