Solved

PHP - Recent posts by Category on my Home page

Posted on 2011-03-04
5
237 Views
Last Modified: 2012-05-11
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
Comment
Question by:livewirewebsolutions
  • 2
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
gizmola earned 225 total points
ID: 35040532
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
 
LVL 31

Assisted Solution

by:gwkg
gwkg earned 100 total points
ID: 35044921
category="3,5,6"

where 3, 5 and 6 are the categories you want to include.
0
 

Author Closing Comment

by:livewirewebsolutions
ID: 35070332
Works perfectly.

Do either of you know how where to find the category number?
0
 
LVL 4

Expert Comment

by:gizmola
ID: 35072835
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
 

Author Comment

by:livewirewebsolutions
ID: 35072934
thanks gizmola.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question