- This topic has 3 replies, 2 voices, and was last updated 3 years, 12 months ago by
Tom.
-
AuthorPosts
-
March 31, 2019 at 6:21 pm #855338
Todd
I have a webcomic that used to have a nav menu above and below the comic (you guys helped a lot with getting it working). Suddenly, sometime in the last 24 hours or so, the second menu (the one below the webcomic) disappeared. I’m not quite sure what happened, especially since I haven’t been fiddling with any of the php or css files recently. Hoping you guys can take a quick look and point me in the right direction. Note, I have this code in my function.php (and haven’t edited it in a couple weeks).
edit: One thought I just had is that I recently set up the site to force https. I don’t see why that would impact the second nav bar, but I wanted to mention it since that’s the only significant thing I’ve done recently.
<?php add_action( 'generate_before_main_content', function() { if ( function_exists( 'previous_post_link' ) && function_exists( 'next_post_link' ) ) { echo '<div class="post-navigation">'; echo previous_post_link(); //Older Link using max_num_pages echo next_post_link(); //Newer Link using max_num_pages echo '</div>'; } } ); add_action( 'generate_paging_navigation', function() { if ( function_exists( 'previous_post_link' ) && function_exists( 'next_post_link' ) ) { echo '<div class="post-navigation">'; echo previous_post_link(); //Older Link using max_num_pages echo next_post_link(); //Newer Link using max_num_pages echo '</div>'; } } ); add_filter( 'next_post_link', function( $output, $format, $link, $post ) { $currentID = get_the_ID(); $args = array( 'numberposts' => 1, 'order' => 'ASC', 'orderby' => 'rand', 'post__not_in' => array( $currentID ), ); $random_post = get_posts( $args ); if ( ! $post ) { $next = sprintf( '<a class="next-post" href="%1$s" title="%2$s"></a>', get_permalink( $post ), $post->post_title ); $random_post = sprintf( '<a class="random-post" href="%1$s" title="%2$s"></a>', get_permalink( $random_post[0]->ID ), get_the_title( $random_post[0]->ID ) ); $last_post = get_posts( 'numberposts=1&order=ASC' ); $last_post = sprintf( '<a class="last-post" href="%1$s" title="%2$s"></a>', get_permalink( $last_post[0]->ID ), get_the_title( $last_post[0]->ID ) ); return $random_post . $next . $last_post; } else { $next = sprintf( '<a class="next-post" href="%1$s" title="%2$s"></a>', get_permalink( $post ), $post->post_title ); $random_post = sprintf( '<a class="random-post" href="%1$s" title="%2$s"></a>', get_permalink( $random_post[0]->ID ), get_the_title( $random_post[0]->ID ) ); $last_post = get_posts( 'numberposts=1&order=ASC' ); $last_post = sprintf( '<a class="last-post" href="%1$s" title="%2$s"></a>', get_permalink( $last_post[0]->ID ), get_the_title( $last_post[0]->ID ) ); return $random_post . $next . $last_post; } }, 10, 4 ); add_filter( 'previous_post_link', function( $output, $format, $link, $post ) { if ( ! $post ) { $prev = sprintf( '<a class="previous-post" href="%1$s" title="%2$s"></a>', get_permalink( $post ), $post->post_title ); $latest_post = get_posts( 'numberposts=1' ); $latest_post = sprintf( '<a class="latest-post" href="%1$s" title="%2$s"></a>', get_permalink( $latest_post[0]->ID ), get_the_title( $latest_post[0]->ID ) ); return $latest_post . $prev; } else{ $prev = sprintf( '<a class="previous-post" href="%1$s" title="%2$s"></a>', get_permalink( $post ), $post->post_title ); $latest_post = get_posts( 'numberposts=1' ); $latest_post = sprintf( '<a class="latest-post" href="%1$s" title="%2$s"></a>', get_permalink( $latest_post[0]->ID ), get_the_title( $latest_post[0]->ID ) ); return $latest_post . $prev; } }, 10, 4 );
GeneratePress 2.2.2GP Premium 1.7.8April 1, 2019 at 8:24 am #855942Tom
Lead DeveloperLead DeveloperThat’s strange.. Instead of:
add_action( 'generate_paging_navigation', function() { if ( function_exists( 'previous_post_link' ) && function_exists( 'next_post_link' ) ) { echo '<div class="post-navigation">'; echo previous_post_link(); //Older Link using max_num_pages echo next_post_link(); //Newer Link using max_num_pages echo '</div>'; } } );
Try this:
add_action( 'generate_after_main_content', function() { if ( function_exists( 'previous_post_link' ) && function_exists( 'next_post_link' ) ) { echo '<div class="post-navigation">'; echo previous_post_link(); //Older Link using max_num_pages echo next_post_link(); //Newer Link using max_num_pages echo '</div>'; } } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 1, 2019 at 1:58 pm #856263Todd
Thanks, Tom. That worked! No hurry on a response, but do you know why that would have fixed it? I always like to understand things in the hopes that I can avoid asking a question in the future. 🙂
April 1, 2019 at 4:07 pm #856333Tom
Lead DeveloperLead DeveloperI didn’t know for sure, but the
generate_after_main_content
hook should always exist.generate_paging_navigation
only exists if WP thinks it needs it (which it should in your case).Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.