Solved

PHP - Recent posts by Category on my Home page

Posted on 2011-03-04
5
238 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to count occurrences of each item in an array.

756 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