Solved

PHP - Recent posts by Category on my Home page

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The viewer will learn how to dynamically set the form action using jQuery.

770 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