Next & Previous blog post links
-
I’ve been handed a wordpress site that someone else built, and I can’t seem to figure-out how to add Next and Previous blog post links to it. I wonder if anyone here can help. The blog page is at https://globalseafoods.com/news/
The theme appears to be a custom build from Sir Speedy.
I’m not sure what code to add to which file.
Thank you!
Cameron
-
look into index.php or home.php (if exists);
general, review http://codex.wordpress.org/Pagination
Hi, Alchymyth.
Thank you for responding.
I found an index.php file in the framework folder.
Below is what’s in it. I didn’t find a home.php file. Is the below index.php file the one I’m wanting?<?php get_header(); /* Let's get the loop * Change the second variable in the get_template_part() to fit your needs. * Choose a preset option, or create your own custom loop and call it here. * For more information on get_template_part() visit * http://codex.wordpress.org/Function_Reference/get_template_part * * Preset options include: * 'excerpt' - displays the posts as the_excerpt() * 'content' - displays the posts as the_content() * 'list' - displays a number of posts as the_excerpt() or the_content(), * a list of the remaining posts as links. */ $myloop = get_option('developer_add_blog'); if($myloop == "disabled") { ?> <div id="main"> <div id="post" class="post"> <h1>Nothing Found</h1> <p><?php _e('Sorry, but we looked everywhere and could not find the page you requested.'); ?></p> </div><!-- #post --> </div><!-- #main --> <?php ; } else { get_template_part( 'loop' , $myloop ); } get_template_part( 'side' , 'index' ); get_footer(); ?>This is interesting: when I view the source of globalseafoods.com/news/ I see this in the head tag: <link rel=”next” href=”https://globalseafoods.com/news/page/2/” />
get_template_part( ‘side’ , ‘index’ );
does your theme have a file side-index.php?
No. There is a side.php file in the framework folder.
have a look into that side.php file, to see if the loop structure is there…
Looking at the index.php file, it says at the top, “Let’s get the loop”. Isn’t the loop structure in the index.php file?
Here’s what’s in the side.php file:<div id="side"> <?php $sidebar_html = get_post_meta($post->ID, '_wpdev_sb_html', true); $sidebar_html_loc = get_post_meta($post->ID, '_wpdev_sb_html_loc', true); if($sidebar_html) { if($sidebar_html_loc == 'above') get_sidebar('sideabove'); } $selected_sidebar = get_post_meta($post->ID, '_wpdev_selected_sb', true); if($selected_sidebar == "0") { return; } elseif($selected_sidebar == "2") { get_sidebar('side2'); } elseif($selected_sidebar == "3") { get_sidebar('side3'); } elseif($selected_sidebar == "4") { get_sidebar('side4'); } elseif($selected_sidebar == "5") { get_sidebar('side5'); } elseif($selected_sidebar == "6") { get_sidebar('side6'); } elseif($selected_sidebar == "7") { get_sidebar('side7'); } elseif($selected_sidebar == "8") { get_sidebar('side8'); } elseif($selected_sidebar == "9") { get_sidebar('side9'); } elseif($selected_sidebar == "10") { get_sidebar('side10'); } elseif($selected_sidebar == "11") { get_sidebar('side11'); } elseif($selected_sidebar == "12") { get_sidebar('side12'); } elseif($selected_sidebar == "13") { get_sidebar('side13'); } elseif($selected_sidebar == "14") { get_sidebar('side14'); } elseif($selected_sidebar == "15") { get_sidebar('side15'); } elseif($selected_sidebar == "16") { get_sidebar('side16'); } elseif($selected_sidebar == "17") { get_sidebar('side17'); } elseif($selected_sidebar == "18") { get_sidebar('side18'); } elseif($selected_sidebar == "19") { get_sidebar('side19'); } elseif($selected_sidebar == "20") { get_sidebar('side20'); } else { get_sidebar('side1'); } if($sidebar_html) { if($sidebar_html_loc == 'below') get_sidebar('sidebelow'); } ?> </div><!-- #side -->forget side.php – my mistake – I should have pointed you to loop.php
Ok. Below is loop.php.
I visited the pagination page you sent. I’m unsure where to put
<div class="navigation"><p><?php posts_nav_link(); ?></p></div>I took a couple guesses, but nothing showed-up when I refreshed the page.
<?php /* The Basic Loop * Uses the_content() to display blog posts */ ?> <div id="main"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php get_template_part( 'meta' , 'author' ); ?> <div class="entry"> <?php the_content(); ?> </div><!-- .entry --> <?php get_template_part( 'meta' , 'details' ); ?> </div><!-- #post-<?php the_ID(); ?> --> <?php endwhile; else: ?> <div id="post" class="post"> <h2>Nothing Found</h2> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> </div><!-- #post --> <?php endif; ?> </div><!-- #main -->here in this line should work:
<?php endwhile; else: ?>for example so:
<?php endwhile; ?> <div class="navigation"><p><?php posts_nav_link(); ?></p></div> <?php else: ?>or directly after this line:
<?php endif; ?>That didn’t work. I tried it in both of your suggested locations, and in other files with loop in the name, and nothing seems to be working.
Any other ideas?
Thanks, Alchymythdoes anything added into these locations show?
are you using any cache plugin?No. I typed asdf in place of where I pasted the posts_nav_link code, saved, uploaded, refreshed. Nothing.
I don’t see a cache plug-in, either.
I think I’m going to set the Reading settings to show 100 blog posts, and forget about it. Can I send you some $ for your help?
The topic ‘Next & Previous blog post links’ is closed to new replies.