Solved

PHP - Recent posts by Category on my Home page

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now