- This topic has 15 replies, 2 voices, and was last updated 3 years, 9 months ago by Leo.
-
AuthorPosts
-
May 18, 2017 at 2:43 pm #320317miguel
Hi,
I would like to delete the previous/next post link. I know how to do it with CSS, but I don’t want to hide it, I want to remove it at all for SEO purposes. I don’t want Google to crawl these links.
I recently purchased the premium theme and I thought it would be possible to remove it, but it is not. Is there any way to do it?
Thanks
Miguel
May 18, 2017 at 10:36 pm #320444LeoStaffCustomer SupportHi Miguel,
This should do it: https://gist.github.com/generatepress/81709146251f7a9b645a
Adding PHP: https://docs.generatepress.com/article/adding-php/
May 19, 2017 at 2:26 am #320570miguelHi Leo,
This is exactly what I was looking for.
Thank you very much.
Miguel
May 19, 2017 at 9:00 am #320756LeoStaffCustomer SupportCredit to Tom π Glad I could help!
December 28, 2017 at 11:12 am #458704NicholasHi, I’m trying to do the same. Where do I place the code mentioned above?
December 28, 2017 at 2:40 pm #458841LeoStaffCustomer SupportSee the adding PHP link here: https://generatepress.com/forums/topic/disable-nextprevious-post/#post-320444
April 7, 2019 at 12:55 am #861798MihaHey,
I have installed Code snippet plugin and inserted php code in it.
Activated it, but nothing happens. Previous/next posts are still there.Is the code mentioned above still relevant?
Thanks!
April 7, 2019 at 3:17 am #861850DavidStaffCustomer SupportHi there,
you can disable the single post navigation in Customizer > Layout > Blog –> Single: Post Navigation.
Make sure you have the Blog module activated in Appearance > GeneratePress.
April 7, 2019 at 6:19 am #861915MihaHey David,
I have Post navigation disabled, but there are still image links to previous/next post.
For example: http://hupi.si/2018/09/20/aside-for-widgets/This element:
<a class=”post-previous” …What now?
April 7, 2019 at 7:05 am #862067DavidStaffCustomer SupportThe Dispatch site uses a custom function for that. Go to Appearance > Elements and delete ( or save as a draft ) the Custom Post Navigation hook element.
April 9, 2019 at 8:01 am #864118MihaIt works.
Thanks much! π
April 9, 2019 at 8:06 am #864127DavidStaffCustomer SupportYou’re welcome
September 2, 2019 at 1:43 am #998897Mattwhere to I add below code to disable previous/next link at footer?
if ( ! function_exists( ‘generate_content_nav’ ) ) :
/**
* Display navigation to next/previous pages when applicable
*/
function generate_content_nav( $nav_id ) {global $wp_query, $post;
// Don’t print empty markup on single pages if there’s nowhere to navigate.
if ( is_single() ) {
$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, ”, true );
$next = get_adjacent_post( false, ”, false );if ( ! $next && ! $previous )
return;
}// Don’t print empty markup in archives if there’s only one page.
if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) )
return;$nav_class = ( is_single() ) ? ‘post-navigation’ : ‘paging-navigation’;
?>
<nav role=”navigation” id=”<?php echo esc_attr( $nav_id ); ?>” class=”<?php echo $nav_class; ?>”>
<h6 class=”screen-reader-text”><?php _e( ‘Post navigation’, ‘generate’ ); ?></h6><?php if ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
<?php if ( get_next_posts_link() ) : ?>
<span class=”prev” title=”<?php _e(‘Previous’,’generate’);?>”><?php next_posts_link( __( ‘Older posts’, ‘generate’ ) ); ?></span><?php endif; ?>
<?php if ( get_previous_posts_link() ) : ?>
<span class=”next” title=”<?php _e(‘Next’,’generate’);?>”><?php previous_posts_link( __( ‘Newer posts’, ‘generate’ ) ); ?></span><?php endif;
if ( function_exists( ‘the_posts_pagination’ ) ) {
the_posts_pagination( array(
‘mid_size’ => apply_filters( ‘generate_pagination_mid_size’, 1 ),
‘prev_text’ => apply_filters( ‘generate_previous_link_text’, __( ‘← Previous’, ‘generatepress’ ) ),
‘next_text’ => apply_filters( ‘generate_next_link_text’, __( ‘Next →’, ‘generatepress’ ) ),
) );
}do_action(‘generate_paging_navigation’); ?>
<?php endif; ?>
</nav><!– #<?php echo esc_html( $nav_id ); ?> –>
<?php
}
endif; // generate_content_navSeptember 2, 2019 at 2:30 am #998922DavidStaffCustomer SupportHi there,
i replied here to that question:
https://generatepress.com/forums/topic/nextprevious-post-links-on-cpt/#post-998888July 5, 2020 at 11:28 am #1352939OlivierHello,
When I insert this code “Remove next/previous post links completely” in code snippets, it tells me
The code snippet has been disabled due to an error on line 6: Cannot redeclare function generate_content_nav.
Thanks π
-
AuthorPosts
- The topic ‘Disable next/previous post’ is closed to new replies.