Jump to content


Photo

Wordpress programming


  • Please log in to reply
6 replies to this topic

#1 virtual

virtual

    Advanced Member

  • Advanced Member
  • PipPipPipPip
  • 883 posts
  • LocationLa Jolla, California

Posted 24 September 2011 - 06:33 AM

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('&laquo; Older Entries') ?></div>
	<div class="prev-posts"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
</div>

Any help would be greatly appreciated.
  • 0
Lynne
180virtual

#2 Ben

Ben

    Administrator

  • Administrators
  • 5,638 posts
  • LocationChico, CA

Posted 24 September 2011 - 10:29 AM

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/201...tion-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....ess-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.
  • 0
Benjamin Falk
Falken Creative : Twitter

#3 virtual

virtual

    Advanced Member

  • Advanced Member
  • PipPipPipPip
  • 883 posts
  • LocationLa Jolla, California

Posted 24 September 2011 - 11:56 AM

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
  • 0
Lynne
180virtual

#4 Ben

Ben

    Administrator

  • Administrators
  • 5,638 posts
  • LocationChico, CA

Posted 24 September 2011 - 12:22 PM

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.
  • 1
Benjamin Falk
Falken Creative : Twitter

#5 virtual

virtual

    Advanced Member

  • Advanced Member
  • PipPipPipPip
  • 883 posts
  • LocationLa Jolla, California

Posted 24 September 2011 - 12:56 PM

OK thanks a lot
  • 0
Lynne
180virtual

#6 virtual

virtual

    Advanced Member

  • Advanced Member
  • PipPipPipPip
  • 883 posts
  • LocationLa Jolla, California

Posted 25 September 2011 - 10:13 AM

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, 25 September 2011 - 10:14 AM.

  • 0
Lynne
180virtual

#7 seemasaiyom

seemasaiyom

    New member

  • New Members
  • 3 posts

Posted 05 November 2011 - 03:41 AM

Hi,

i have a little knowledge of that but i am interested to know more about that..

this information can be helpful for me as well as for others..

Thanks.
[De-spammed]
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users