Jump to content
Sign in to follow this  
saidseven

Adding post previews to a page.

Recommended Posts

saidseven

Hello, First here is my page... http://74.206.232.168/events/ I'm trying to add a row of 3 post "previews" from a specified category at the top of the page. I tried doing this via a carousel but i would like a little bit more text to show along with the thumbnail exactly like the default posts page. I tried doing it via boxes but id rather not have to make boxes manually because the event are posts already. What would be the best way to achieve this? Is there a way to insert a code snipet that will create this? Thanks in advance.

Share this post


Link to post
Share on other sites
cmunns

I would create a custom loop. It shouldn't be too hard, but you can't addd PHP in the post editor so you'll have to use a hook Something like this as a start: ` <?php $myPosts = new WP_Query(); $myPosts->query('showposts=5'); while ($myPosts->have_posts()) : $myPosts->the_post(); ?> the_title(); the_content(); endwhile; ?> `

Share this post


Link to post
Share on other sites
saidseven

Thanks Adam. I went into my functions.php file and added this...

	
	function add_postpreview(){
			?>
	
	$myPosts = new WP_Query();
	$myPosts->query('showposts=5');
	
	while ($myPosts->have_posts()) : $myPosts->the_post(); ?>
	the_title();
	the_content();
	endwhile;
	
	<?php }
		// end function
	

but when i preview it i get... http://74.206.232.168/events/ what am i doing wrong?

Share this post


Link to post
Share on other sites
catrina

Where the code is placed affects whether or not it will work. Where in the editor did you place the code (below which code did you add it)?


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
saidseven

Hello Katrina I ended up loading a plugin called shorcode Exec PHP. Its pretty amazing in that it lets you insert php in a post page and make shortcodes. This is the actual php loop that is running at the bottom of the page. query_posts('showposts=3'); $ids = array(); while (have_posts()) : the_post(); the_title(); the_content(); endwhile; if you look on the page you can see that its showing the data twice and its staggering the layout. Is my syntax correct on my code?

Share this post


Link to post
Share on other sites
catrina

If you have any other plugins activated, you might want to deactivate those one by one first to see if they're causing a conflict with your PHP plugin.


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×