Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

PHP - Recent posts by Category on my Home page

I am currently using the below code to allow recent posts to my homepage.  I am using a Wordpress Plugin called Get Posts.  http://wordpress.org/extend/plugins/nurelm-get-posts/

Currently, all posts are appearing.  How do I change this php code below so only certain categories appear?

As per this page http://codex.wordpress.org/Template_Tags/get_posts it looks like I can filter by Category or Category Name.
[get_posts numberposts=10 orderby="post_date" fields="post_title, post_excerpt" fields_make_link="true, false, false"]

Open in new window

0
livewirewebsolutions
Asked:
livewirewebsolutions
  • 2
  • 2
2 Solutions
 
gizmolaCommented:
Looks like you can add either

category="3"  where the 3 would be whatever the id is of the category you want or category_name="blah" would be the name.

There is no way to provide a list of categories in the plugin, although I'm guessing that would be a small modification to the code.
0
 
gwkgCommented:
category="3,5,6"

where 3, 5 and 6 are the categories you want to include.
0
 
livewirewebsolutionsAuthor Commented:
Works perfectly.

Do either of you know how where to find the category number?
0
 
gizmolaCommented:
One way would be looking at the wordpress database using phpMyAdmin or command line mysql.  This site provides a good reference.  I'm not sure how much the database has changed over versions, but they do seem to have a pretty nice historic record of the different schemas.

Currently it looks to me like you would want to look at the wp_terms table where term_id should be your category id.
0
 
livewirewebsolutionsAuthor Commented:
thanks gizmola.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now