Community Forums › Forums › Archived Forums › Design Tips and Tricks › Magazine Pro Difficulties with Hooks and prev and post nav links
Tagged: hooks
- This topic has 4 replies, 2 voices, and was last updated 7 years ago by Af-media.
-
AuthorPosts
-
November 18, 2017 at 8:37 am #213712Af-mediaParticipant
Hi,
I would like to add previous and post navigation to articles of the same category and I would like the navigation links to appear above the author box which is linked to the genesis_entry_footer.
Here is the code in the function.php file of my magazine pro theme.
`remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 10 );
//* Add previous and next post links after entry
add_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav',7 );
//change hook for position
add_action( 'genesis_entry_footer', 'themeprefix_alt_author_box', 9 );The result is that the navigation links are under the author box... Nothing happens if I swap the priority of the two add_action() functions.
Further more, if I try to attach the nav links to another hooks (genesis_after_content for example), nothing happens neither.
I can post the whole function.php file if it helps.Thanks for reading,
http://les-parameennes.fr/mode-st-malo/balade-dautomne/1648/
AmandineNovember 19, 2017 at 5:32 am #213731Victor FontModeratorYou're targeting the wrong action. If you look at the Genesis source code, the genesis_prev_next_post_nav action does one thing. It adds post type support for the genesis-adjacent-entry-nav action. Essentially, it enables this action. If you want to move the navigation above the author box you have to:
remove_action( 'genesis_after_entry', 'genesis_adjacent_entry_nav' ); add_action( 'genesis_entry_footer', 'genesis_adjacent_entry_nav',7 )
You'll find the related source code at the bottom of post.php in the genesis/lib/structure directory.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?November 19, 2017 at 6:57 am #213736Af-mediaParticipantHi Victor,
Thanks for the suggestion. Unfortunatly it doesn't display anything...
Here is the function.php if it helps (the code is line 159)<?php //* Start the engine include_once( get_template_directory() . '/lib/init.php' ); //* Setup Theme include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' ); //* Set Localization (do not remove) load_child_theme_textdomain( 'magazine', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'magazine' ) ); //* Child theme (do not remove) define( 'CHILD_THEME_NAME', __( 'Magazine Pro Theme', 'magazine' ) ); define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/magazine/' ); define( 'CHILD_THEME_VERSION', '3.1' ); //* Enqueue Google Fonts and JS script add_action( 'wp_enqueue_scripts', 'magazine_enqueue_scripts' ); function magazine_enqueue_scripts() { wp_enqueue_script( 'magazine-entry-date', get_bloginfo( 'stylesheet_directory' ) . '/js/entry-date.js', array( 'jquery' ), '1.0.0' ); wp_enqueue_script( 'magazine-responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' ); wp_enqueue_style( 'dashicons' ); wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Roboto:300,400|Raleway:400,500,900', array(), CHILD_THEME_VERSION ); } //* Add HTML5 markup structure add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) ); //* Add viewport meta tag for mobile browsers add_theme_support( 'genesis-responsive-viewport' ); //* Add new image sizes add_image_size( 'home-middle', 360, 200, true ); add_image_size( 'home-top', 750, 420, true ); add_image_size( 'sidebar-thumbnail', 100, 100, true ); //* Add support for additional color styles add_theme_support( 'genesis-style-selector', array( 'magazine-pro-blue' => __( 'Magazine Pro Blue', 'magazine' ), 'magazine-pro-green' => __( 'Magazine Pro Green', 'magazine' ), 'magazine-pro-orange' => __( 'Magazine Pro Orange', 'magazine' ), ) ); //* Add support for custom header add_theme_support( 'custom-header', array( 'default-text-color' => '000000', 'header-selector' => '.site-title a', 'header-text' => true, 'height' => 90, 'width' => 380, ) ); //* Add support for custom header blog title function header_right_content () { echo '<div class="header-right"><h2> <span class="main-blog-title"> Mode etc .</span> <br/> <span class="secondary-blog-title"> à Paramé - Saint-Malo </span></h2></div>'; }; add_action('genesis_header_right', 'header_right_content'); remove_action ( 'genesis_site_title', 'genesis_seo_site_title' ); add_action( 'genesis_before_header', 'genesis_seo_site_title' ); //* Remove the site description remove_action( 'genesis_site_description', 'genesis_seo_site_description' ); //* Add support for blog logo in site_description function site_description_content () { echo '<div class="site-logo"><a href="http://les-parameennes.fr"> <img width="300" src="http://les-parameennes.fr/wp-content/uploads/2016/03/les-parameennes.png"></a></div>'; }; add_action('genesis_site_description', 'site_description_content'); //* Reposition the primary navigation menu remove_action( 'genesis_before_header', 'genesis_do_nav' ); add_action( 'genesis_before', 'genesis_do_nav' ); //* Add primary-nav class if primary navigation is used add_filter( 'body_class', 'backcountry_no_nav_class' ); function backcountry_no_nav_class( $classes ) { $menu_locations = get_theme_mod( 'nav_menu_locations' ); if ( ! empty( $menu_locations['primary'] ) ) { $classes[] = 'primary-nav'; } return $classes; } //* Customize search form input box text add_filter( 'genesis_search_text', 'magazine_search_text' ); function magazine_search_text( $text ) { return esc_attr( __( 'Rechercher sur le blog ...', 'magazine' ) ); } //customizing authorbox and contact fields thanks to function themeprefix_modify_user_contact_methods( $user_contact ){ /* Add user contact methods */ $user_contact['facebook'] = __( 'Facebook URL' ); return $user_contact; } add_filter( 'user_contactmethods', 'themeprefix_modify_user_contact_methods' ); //Load Fontawesome function themeprefix_fontawesome_styles() { wp_register_style( 'fontawesome' , '//netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.css', '' , '4.4.0', 'all' ); wp_enqueue_style( 'fontawesome' ); } add_action( 'wp_enqueue_scripts', 'themeprefix_fontawesome_styles' ); //custom author box with social links function themeprefix_alt_author_box() { if( is_single() ) {?> <div class="author-box"><?php echo get_avatar( get_the_author_meta( 'ID' ), '70' ); ?> <div class="about-author"><h4>À propos de <?php echo get_the_author(); ?></h4><p><?php echo get_the_author_meta( 'description' ); ?> </div> <div class="all-posts"><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' )); ?>">Voir tous les articles de <?php echo get_the_author(); ?></a></div> <ul class="social-links"> <?php if ( get_the_author_meta( 'facebook' ) != '' ): ?> <li><a href="<?php echo get_the_author_meta( 'facebook' ); ?>"><i class="fa fa-facebook"></i></a></li> <?php endif; ?> <?php if ( get_the_author_meta( 'twitter' ) != '' ): ?> <li><a href="https://twitter.com/<?php echo get_the_author_meta( 'twitter' ); ?>"><i class="fa fa-twitter"></i></a></li> <?php endif; ?> <?php if ( get_the_author_meta( 'googleplus' ) != '' ): ?> <li><a href="<?php echo get_the_author_meta( 'googleplus' ); ?>"><i class="fa fa-google-plus"></i></a></li> <?php endif; ?> <?php if ( get_the_author_meta( 'github' ) != '' ): ?> <li><a href="<?php echo get_the_author_meta( 'github' ); ?>"><i class="fa fa-github"></i></a></li> <?php endif; ?> <?php if ( get_the_author_meta( 'user_email' ) != '' ): ?> <li><a href="mailto:<?php echo get_the_author_meta( 'user_email' ); ?>"><i class="fa fa-envelope-o"></i></a></li> <?php endif; ?> <?php if ( get_the_author_meta( 'user_url' ) != '' ): ?> <li><a href="<?php echo get_the_author_meta( 'user_url' ); ?>"><i class="fa fa-laptop"></i> </a></li> <?php endif; ?> </ul> </div> <?php } } remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 10 ); //* Add previous and next post links after entry //*add_action( 'genesis_after_content', 'genesis_prev_next_post_nav',7 ); remove_action( 'genesis_after_entry', 'genesis_adjacent_entry_nav' ); add_action( 'genesis_entry_footer', 'genesis_adjacent_entry_nav',7 ); add_action( 'genesis_entry_footer', 'themeprefix_alt_author_box', 9 ); //change hook for position //* Display author box on single posts /*add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );*/ //* Display author box on archive pages /*add_filter( 'get_the_author_genesis_author_box_archive', '__return_true' );*/ //* Customize the author box title /*add_filter( 'genesis_author_box_title', 'custom_author_box_title' ); function custom_author_box_title() { return '<strong>À propos de l\'auteur </strong>'; } add_action( 'genesis_after_entry', 'genesis_do_author_box_on_page', 8 ); function genesis_do_author_box_on_page(){ if ( ! is_singular('page') ) return; if ( get_the_author_meta( 'genesis_author_box_single', get_the_author_meta( 'ID' ) ) ) genesis_author_box( 'single' ); } //* Modify the size of the Gravatar in the author box add_filter( 'genesis_author_box_gravatar_size', 'magazine_author_box_gravatar' ); function magazine_author_box_gravatar( $size ) { return 140; }*/ //* Modify the size of the Gravatar in the entry comments add_filter( 'genesis_comment_list_args', 'magazine_comments_gravatar' ); function magazine_comments_gravatar( $args ) { $args['avatar_size'] = 100; return $args; } //* Remove entry meta in entry footer add_action( 'genesis_before_entry', 'magazine_remove_entry_meta' ); function magazine_remove_entry_meta() { //* Remove if not single post if ( ! is_single() ) { remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); } } //* Remove comment form allowed tags add_filter( 'comment_form_defaults', 'magazine_remove_comment_form_allowed_tags' ); function magazine_remove_comment_form_allowed_tags( $defaults ) { $defaults['comment_notes_after'] = ''; return $defaults; } //* Add support for 3-column footer widgets add_theme_support( 'genesis-footer-widgets', 3 ); //* Add support for after entry widget add_theme_support( 'genesis-after-entry-widget-area' ); //* Relocate after entry widget remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' ); add_action( 'genesis_entry_footer', 'genesis_after_entry_widget_area' ); //* Register widget areas genesis_register_sidebar( array( 'id' => 'home-top', 'name' => __( 'Home - Top', 'magazine' ), 'description' => __( 'This is the top section of the homepage.', 'magazine' ), ) ); genesis_register_sidebar( array( 'id' => 'home-middle', 'name' => __( 'Home - Middle', 'magazine' ), 'description' => __( 'This is the middle section of the homepage.', 'magazine' ), ) ); genesis_register_sidebar( array( 'id' => 'home-bottom', 'name' => __( 'Home - Bottom', 'magazine' ), 'description' => __( 'This is the bottom section of the homepage.', 'magazine' ), ) ); //* Custom Search form in French /** Customize search form input box text */ add_filter( 'genesis_search_text', 'custom_search_text' ); function custom_search_text( $text ) { return esc_attr( 'Rechercher sur le blog...' ); } //* Display a custom favicon add_filter( 'genesis_pre_load_favicon', 'sp_favicon_filter' ); function sp_favicon_filter( $favicon_url ) { return 'http://www.mydomain.com/wp-content/themes/genesis/images/favicon.ico'; } add_filter( 'excerpt_more', 'genesischild_read_more_link', 2 ); /** Customize the read more link */ add_filter( 'get_the_content_more_link', 'custom_read_more_link' ); function custom_read_more_link() { return '... <a class="more-link" href="' . get_permalink() . '">[Lire la suite]</a>'; }
November 20, 2017 at 5:19 am #213779Victor FontModeratorI'm seeing the navigation just fine. On your sample post above, I see this:
« La petite histoire de la Braderie de Paramé.
Chic & Mode , le choix d’Enora »
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?November 20, 2017 at 5:39 am #213781Af-mediaParticipantYes, because It's the old code, the only one that works :
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 10 ); //* Add previous and next post links after entry remove_action( 'genesis_after_entry', 'genesis_prev_next_post_nav' ); add_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav',7 ); add_action( 'genesis_entry_footer', 'themeprefix_alt_author_box', 9 ); //change hook for position
I just want to put these links above the author box !
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.