Community Forums › Forums › Archived Forums › Design Tips and Tricks › How do I had links to the next and previous post at then end of my single posts?
- This topic has 9 replies, 5 voices, and was last updated 9 years, 5 months ago by
Brian Dusablon.
-
AuthorPosts
-
October 25, 2013 at 7:20 am #68819
rick4him
MemberI would like to put two boxes at the end of each post that has the title of the previous and next post on my site. How would I go about doing that?
Thanks!
October 25, 2013 at 10:09 am #68848emasai
ParticipantThis article from Brad Dalton might help
http://wpsites.net/web-design/next-previous-post-links-genesis/
Need Website Customization or a Responsive CSS fix? Contact Me
Lynne emasai.comOctober 25, 2013 at 1:24 pm #68891rick4him
MemberThanks, but that doesn't put the title to the previous and next post in there does it?
December 23, 2013 at 12:33 pm #80921Brian Dusablon
ParticipantRick, it has instructions for turning the title on. (change no to yes in the page links code).
December 23, 2013 at 12:34 pm #80922Brian Dusablon
ParticipantI'm having another issue. This code isn't working for me.
Here's entire functions.php:
<?php //* Start the engine include_once( get_template_directory() . '/lib/init.php' ); //* Set Localization (do not remove) load_child_theme_textdomain( 'eleven40', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'eleven40' ) ); //* Child theme (do not remove) define( 'CHILD_THEME_NAME', __( 'eleven40 Pro Theme', 'eleven40' ) ); define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/eleven40/' ); define( 'CHILD_THEME_VERSION', '2.0' ); //* Add HTML5 markup structure add_theme_support( 'html5' ); //* Add viewport meta tag for mobile browsers add_theme_support( 'genesis-responsive-viewport' ); //* Load Lora and Oswald Google fonts add_action( 'wp_enqueue_scripts', 'eleven40_google_fonts' ); function eleven40_google_fonts() { wp_enqueue_style( 'google-font', '//fonts.googleapis.com/css?family=Lora:400,700|Oswald:400', array(), PARENT_THEME_VERSION ); } //* Add new featured image size add_image_size( 'grid-featured', 270, 100, TRUE ); //* Add support for custom header add_theme_support( 'custom-header', array( 'width' => 320, 'height' => 65, 'header-selector' => '.site-header .title-area', 'header-text' => false ) ); //* Add support for structural wraps add_theme_support( 'genesis-structural-wraps', array( 'header', 'nav', 'subnav', 'site-inner', 'footer-widgets', 'footer' ) ); //* Add support for additional color styles add_theme_support( 'genesis-style-selector', array( 'eleven40-pro-blue' => __( 'eleven40 Pro Blue', 'eleven40' ), 'eleven40-pro-green' => __( 'eleven40 Pro Green', 'eleven40' ), 'eleven40-pro-red' => __( 'eleven40 Pro Red', 'eleven40' ) ) ); //* Reposition the site description remove_action( 'genesis_site_description', 'genesis_seo_site_description' ); //* add_action( 'genesis_before_content_sidebar_wrap', 'genesis_seo_site_description' ); //* Reposition the primary navigation menu remove_action( 'genesis_after_header', 'genesis_do_nav' ); add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_nav' ); //* Reposition the secondary navigation menu remove_action( 'genesis_after_header', 'genesis_do_subnav' ); add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_subnav' ); //* Add support for 3-column footer widgets add_theme_support( 'genesis-footer-widgets', 3 ); // Home Category Removal add_filter('genesis_grid_loop_args', 'exclude_category_from_home'); function exclude_category_from_home($args){ $args['cat'] = '-7'; //Please add your category id return $args; } // AG ADDED // Register Genesis Menus add_theme_support ( 'genesis-menus' , array ( 'primary' => 'Primary Navigation Menu' , 'secondary' => 'Secondary Navigation Menu' ,'mobile' => 'Mobile Navigation Menu' ) ); // Add Support for Structural Wraps add_theme_support( 'genesis-structural-wraps', array( 'header', 'nav', 'menu-mobile', 'subnav', 'site-inner', 'footer-widgets', 'footer') ); add_action( 'genesis_before_header', 'gst_do_mobilenav' ); /** * Create the Mobile Navigation Menu. * * @author Brad Potter * * @link http://www.bradpotter.com * * Based on code from the StudioPress Genesis Framework 2.0 */ function gst_do_mobilenav() { //* Do nothing if menu not supported if ( ! genesis_nav_menu_supported( 'mobile' ) ) return; //* If menu is assigned to theme location, output if ( has_nav_menu( 'mobile' ) ) { $class = 'menu genesis-nav-menu menu-mobile'; if ( genesis_superfish_enabled() ) $class .= ' js-superfish'; $args = array( 'theme_location' => 'mobile', 'container' => '', 'menu_class' => $class, 'echo' => 0, ); $mobilenav = wp_nav_menu( $args ); //* Do nothing if there is nothing to show if ( ! $mobilenav ) return; $mobilenav_markup_open = genesis_markup( array( 'html5' => '<nav %s>', 'xhtml' => '<div id="mobilenav">', 'context' => 'nav-mobile', 'echo' => false, ) ); $mobilenav_markup_open .= genesis_structural_wrap( 'menu-mobile', 'open', 0 ); $mobilenav_markup_close = genesis_structural_wrap( 'menu-mobile', 'close', 0 ); $mobilenav_markup_close .= genesis_html5() ? '</nav>' : '</div>'; $mobilenav_output = $mobilenav_markup_open . $mobilenav . $mobilenav_markup_close; echo apply_filters( 'gst_do_mobilenav', $mobilenav_output, $mobilenav, $args ); } } add_filter( 'genesis_attr_nav-mobile', 'gst_attributes_nav_mobile' ); /** * Add Attributes for Mobile Navigation Menu. * * @author Brad Potter * * @link http://www.bradpotter.com * * Based on code from the StudioPress Genesis Framework 2.0 */ function gst_attributes_nav_mobile( $attributes ) { $attributes['role'] = 'navigation'; $attributes['itemscope'] = 'itemscope'; $attributes['itemtype'] = 'http://schema.org/SiteNavigationElement'; return $attributes; } /** * Register and Enqueue Mobile Navigation Menu script * * @author Brad Potter * * @link http://www.bradpotter.com */ function gst_mobilemenu_script() { wp_register_script( 'mobile-menu', get_stylesheet_directory_uri() . '/js/mobilemenu.js', array('jquery'), '1.0.0', false ); wp_enqueue_script( 'mobile-menu' ); } add_action('wp_enqueue_scripts', 'gst_mobilemenu_script'); /**Register Widgets*/ genesis_register_sidebar( array( 'id' => 'home-featured', 'name' => __( 'Home Featured', 'eleven40' ), 'description' => __( 'This is the home featured section.', 'eleven40' ), ) ); // Next and Previous Post Links function wpsites_npp_navigation_links() { if ( is_single ( ) ) { ?> <?php previous_post('« « %', 'Previous', 'yes'); ?> | <?php next_post('% » » ', 'Next', 'yes'); ?> <?php } } /** * @author Brad Dalton * @learn more http://wp.me/p1lTu0-9z2 */ add_action('genesis_after_post_content', 'wpsites_npp_navigation_links', 5 );
December 23, 2013 at 12:42 pm #80927Genesis Developer
MemberTry this code in functions.php file
add_action( 'genesis_after_entry', 'genesis_do_post_prev_link_single', 4 ); function genesis_do_post_prev_link_single(){ if( is_single()){ echo '<div style="float: left">' . previous_post_link() . '</div><div style="float: right">' .next_post_link() . '</div>'; } }
December 23, 2013 at 1:30 pm #80944Brian Dusablon
ParticipantThanks, Rick - that's a start, but the floats aren't working. Thoughts?
http://mydivorcepal.com/blog/divorce-process/need-hire-divorce-attorney/
December 23, 2013 at 9:39 pm #81011Genesis Developer
MemberPlease modify the code
add_action( 'genesis_after_entry', 'genesis_do_post_prev_link_single', 4 ); function genesis_do_post_prev_link_single(){ if( is_single()){ echo '<div style="float: left; display: inline-block;width: 48%;">' . "\n"; previous_post_link() ; echo '</div><div style="float: right; display: inline-block;width: 48%;">' . "\n"; next_post_link() ; echo '</div>' . "\n"; } }
December 24, 2013 at 1:10 am #81031Brad Dalton
ParticipantPlease copy ALL the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++
//* Add post navigation (requires HTML5 theme support) add_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav' );
This is the code StudioPress have written to add single post previous and next navigation links http://my.studiopress.com/snippets/entry-content/#add-post-navigation
December 24, 2013 at 9:03 am #81067Brian Dusablon
ParticipantThanks Brad. I think I had tried that before, but in combination with some other code, and it didn't work. This one did.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.