Jump to content
Stef's Super Nerd Coding Community
Sign in to follow this  
virtual

Wordpress programming

Recommended Posts

I am customizing a wordpress template running on Genesis and have run into a problem. My client wants the home page to paginate and I am having some difficulty doing it.

 

The Gallery page code is

<div class="homepage-gallery">

<?php $recent = new WP_Query(array('cat' => genesis_get_option('gallery_cat'), 'showposts' => genesis_get_option('number_images'))); while($recent->have_posts()) : $recent->the_post();?>

	<div class="polaroid-bg">

		<div class="boxgrid slidedown">
			<a href="<?php the_permalink() ?>" rel="bookmark"><?php genesis_image(array('format' => 'html', 'size' => 'Gallery', 'attr' => array('class' => 'cover'))); ?></a>
			<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php $title = the_title('','',FALSE); echo substr($title, 0, 60); ?></a></h3>

               <p>by <?php echo genesis_get_custom_field('nickname'); ?></p>
		</div>	

	</div>       

<?php endwhile; ?>
</div>

 

I have figured out that I need to change the first 2 lines so I changed them to:

<?php $recent = new WP_Query(array('cat' => genesis_get_option('gallery_cat'), 'showposts' => genesis_get_option('number_images'))); while(have_posts()) : the_post();?>

but now I only get 10 posts instead of the 15

 

and then I need to add the navigation, something like this but I must be missing a bit of php somewhere.

<div class="navigation">
<div class="next-posts"><?php next_posts_link('« Older Entries') ?></div>
<div class="prev-posts"><?php previous_posts_link('Newer Entries »') ?></div>
</div>

 

Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites

Oddly enough, the stock Wordpress install doesn't come with pagination -- that's something that has to be done with a plugin or custom code. You may want to talk to Genesis about this directly -- perhaps the framework has built in support for pagination? http://www.studiopress.com/contact

 

This might be helpful: http://skyje.com/2010/02/5-excellent-wordpress-pagination-solutions/ and I've personally used the Wordpress PageNavi plugin before. This is a brief runthrough of how to install/use the WP PageNavi plugin: http://www.hongkiat.com/blog/adding-nice-wordpress-pagination/

 

The code you have above would reduce the number of posts on the home page and add next/previous links, but it won't show pagination.

Share this post


Link to post
Share on other sites

Thanks for your reply Ben, I tried Studio Press first of course, but they say the question is beyond the scope of their forum and to hire some to customize, but I'm trying to learn how to do all this myself.

I will take a look at the pagination plugins.

 

So for future reference, does the code I replaced reduce the number of images to 10, because I have set blog pages to show 10 posts?

 

And could you please explain why this statement is used

<?php $recent = new WP_Query etc..

instead of the regular wp loop.

 

Thanks

Share this post


Link to post
Share on other sites

I know very little about the Genesis framework, so I'm not sure exactly how it works... I think, though, that they are using custom post types to store those images. Custom post types usually require a customized WP loop, since you have to specify which post type you want to display.

 

And yes, unless you manually set the number of items to retrieve in the WP_Query, it will return the default value set within the WP admin.

  • Upvote 1

Share this post


Link to post
Share on other sites

Thanks to your help Ben, I managed to get the pagination to work. I'm not very impressed with the StudioPress help forum, I got no help whatsoever from them.

Edited by virtual

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...