• Resolved chuckyybed

    (@chuckyybed)


    I’m using Streamline theme by StudioPress. There’s not a Next/Previous button with official version on the homepage, but I need it just like this guy https://is.gd/6YKI0

    I inserted the code

    <div class="palignleft"><?php previous_posts_link('? Previous Page') ?></div>
    <div class="palignright"><?php next_posts_link('Next Page ?') ?></div>

    I know it will not work because it’s not inside the loop. But the loop is so complicated for me, I can’t understand how to use it.

    Here’s my home.php code, could someone show me how to use it?. Or just tell me the full code. I’ll always be indebted to you for what you’ve done.

    <?php get_header(); ?>
    
    <div id="homepage">
    
    	<div id="contentleft">
    
    		<div class="postarea">
    
    		<?php if (function_exists('gallery_styles')) : ?>
    
            <div id="fcg">
                <?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?>
            </div>
    
    		<?php endif; ?>
    
    			<div class="aheadline">
    				<h3><?php echo cat_id_to_name(get_theme_mod('featured_top_left')); ?></h3>
    			</div>
    
    			<div class="clear"></div>
    
    				<?php $recent = new WP_Query("cat=".get_theme_mod('featured_top_left')."&showposts=".get_theme_mod('featured_top_left_num')); while($recent->have_posts()) : $recent->the_post();?>
    				<?php if( get_post_meta($post->ID, "thumb", true) ): ?>
    				<a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=<?php echo get_theme_mod('featured_top_left_thumb_height'); ?>&w=<?php echo get_theme_mod('featured_top_left_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
    				<?php else: ?>
    				<?php endif; ?>		                
    
    				<h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    				<?php the_content_limit(300, "[".__("Read more", 'studiopress')."]"); ?>
    
    				<hr/>
    
    				<?php endwhile; ?>
                                    <div class="palignleft"><?php previous_posts_link('&laquo; Previous Page') ?></div>
    				<div class="palignright"><?php next_posts_link('Next Page &raquo;') ?></div>
    
    			</div>
    
    	</div>
    
    <?php include(TEMPLATEPATH."/sidebar.php");?>
    
    </div>
    
    <?php //The main column ends  ?>
    
    <?php get_footer(); ?>
Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter chuckyybed

    (@chuckyybed)

    UP

    Thread Starter chuckyybed

    (@chuckyybed)

    thank you

    Thread Starter chuckyybed

    (@chuckyybed)

    T_T

    Thread Starter chuckyybed

    (@chuckyybed)

    thank you

    Unless I am mistaken, you don’t want previous/next_post_link, you want ‘paged’:
    Try changing this:

    <?php $recent = new WP_Query("cat=".get_theme_mod('featured_top_left')."&showposts=".get_theme_mod('featured_top_left_num')); while($recent->have_posts()) : $recent->the_post();?>

    to this:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
       'cat' => get_theme_mod('featured_top_left'),
       'posts_per_page' => get_theme_mod('featured_top_left_num'),
       'paged' => $paged,
    }
    $recent = new WP_Query($args);
    while($recent->have_posts()) : $recent->the_post();?>
    Thread Starter chuckyybed

    (@chuckyybed)

    Thank you so much. But it’s not working.

    Parse error: syntax error, unexpected ‘}’, expecting ‘)’ in XXX/streamline/home.php on line 29

    Sorry, my mistake. Please try this (or change the one line ahead of $recent =):

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
       'cat' => get_theme_mod('featured_top_left'),
       'posts_per_page' => get_theme_mod('featured_top_left_num'),
       'paged' => $paged,
    );
    $recent = new WP_Query($args);
    while($recent->have_posts()) : $recent->the_post();?>

    And, leave in the previous/next_posts_link lines.

    Thread Starter chuckyybed

    (@chuckyybed)

    vtxyzzy You Awesome! You’re absolutely gifted!
    Big Big XOXO for you! I’m extremely grateful to you.

    You are welcome! Now, please use the dropdown at top right to mark this topic ‘Resolved’.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Next/Previous button on homepage ;(’ is closed to new replies.