Solved

wordpress recent posts with category

Posted on 2014-04-16
7
355 Views
Last Modified: 2014-05-01
i am using the shortcode [recent-posts] on a page and its working perfectly.  However, instead of all posts appearing, I want only posts from a certain category to appear.  How do I code this?
0
Comment
Question by:livewirewebsolutions
  • 3
  • 3
7 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40005584
Is this a wordpress.com site or a .org site?

If .org, which plugin are you using to get the shortcode?
0
 

Author Comment

by:livewirewebsolutions
ID: 40005589
its a wordpess site using the twenty twelve theme
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40005599
Haven't answered my questions.

Is this self hosted or hosted through wordpress.com? Twenty Twelve exists on both.

If self hosted, which plugins are installed?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:livewirewebsolutions
ID: 40005617
self hosted.  wordpress shortcodes plugin is installed but i don't think its the reason why [recent-posts] works.  Doesn't that shortcode come with Wordpress?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40005645
Doesn't that shortcode come with Wordpress?

Nope :)

Self-hosted WordPress doesn't come with any shortcodes out of the box...they are added in by coding, themes, and plugins.  Wordpress.com is a different story. Which shortcode plugin is this...there are two or three people who make one?
0
 

Author Comment

by:livewirewebsolutions
ID: 40005650
this is the link to the plugin: http://synved.com/wordpress-shortcodes/
0
 
LVL 15

Accepted Solution

by:
eemit earned 330 total points
ID: 40006432
Try this in your theme's functions.php:
add_filter( 'widget_posts_args', 'yourchildthemeslug_extend_recent_posts_query' );
function yourchildthemeslug_extend_recent_posts_query( $args ) {
	$args['category__in'] = array('2'); //change '2' to your category ID
	
	//use this to show posts from more categories
	//$args['category__in'] = array('2', '3'); //change '2' and '3' to your category IDs

	return $args;
}

Open in new window

Change 'yourchildthemeslug' to your child theme's slug.
If your child theme's slug contains hyphens, replace them with underscores (You can not use a hyphen in a PHP function name).
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
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 purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

760 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

17 Experts available now in Live!

Get 1:1 Help Now