Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #1252581

    JfantasyBooks
    Participant

    Name: JFantasyBooks
    Site: Fantasy-Books
    Site Url: https://fantasy-books.live
    WordPress Version: 4.6.1
    X Version: 4.6.4
    Cornerstone Plugin Version: 1.3.3

    Problem:

    I’m trying to add these buttons to the bottom of my posts, but they are not appearing. Any ideas why? It has to be by php.

    // Additional Navigational Functions
    // =============================================================================
    
    function x_navigation_postsx() {
      
      if ( is_singular('post') ) {
    
      $stack = x_get_stack();
      $is_ltr    = ! is_rtl();
      $prev_post = get_adjacent_post( true, '', true );
      $next_post = get_adjacent_post( true, '', false );
    
    ?>
    
    <div class="x-nav-articles">
    
        <?php if ( $prev_post ) : ?>
        <?php echo do_shortcode('[button type="flat" shape="square" size="large" block="true" href="<?php echo get_permalink( $prev_post ); ?>" class="prev"][icon type="angle-double-right"]Next Chapter[/button]');?>
        <?php endif; ?>
      
        <?php if ( $next_post ) : ?>
          <?php echo do_shortcode('[button type="flat" shape="square" size="large" block="true" href="<?php echo get_permalink( $next_post ); ?>" class="next"][icon type="angle-double-right"]Next Chapter[/button]');?>
        <?php endif; ?>
    
      </div>
    
      <?php
       
       }
    
      }
      
    #1252864

    Rupok
    Member

    Hi there,

    Thanks for writing in! Unfortunately we can’t assist on such custom code. You can check similar function from /framework/functions/global/content.php

    cheers!

    #1252880

    JfantasyBooks
    Participant

    Can you at least tell me a few things?

    Like,

    1. can I indeed put this in the functions.php when I get it right, and it would work? And if not, what .php file am I going for?

    2. Whether that div class for those buttons are correct?

    #1253004

    Rue Nel
    Moderator

    Hello There,

    Thank you for the clarifications! You do have the custom function but you did not hook it to the single post and that is why it is not showing up. Please have your code updated and use this instead:

    // Add a next/previous links at the bottom of the single blog post
    // =============================================================================
    function x_navigation_postsx() {
      
      if ( is_singular('post') ) {
    
      $stack = x_get_stack();
      $is_ltr    = ! is_rtl();
      $prev_post = get_adjacent_post( true, '', true );
      $next_post = get_adjacent_post( true, '', false );
    
    ?>
    
      <div class="x-nav-articles">
    
        <?php if ( $prev_post ) : ?>
        <?php echo do_shortcode('[button type="flat" shape="square" size="large" block="true" href="<?php echo get_permalink( $prev_post ); ?>" class="prev"][icon type="angle-double-right"]Next Chapter[/button]');?>
        <?php endif; ?>
      
        <?php if ( $next_post ) : ?>
          <?php echo do_shortcode('[button type="flat" shape="square" size="large" block="true" href="<?php echo get_permalink( $next_post ); ?>" class="next"][icon type="angle-double-right"]Next Chapter[/button]');?>
        <?php endif; ?>
    
      </div>
    
      <?php
       
      }
    
    }
      
    add_action('x_before_the_content_end', 'x_navigation_postsx');
    // =============================================================================

    Hope this helps. Kindly let us know.

    #1253049

    JfantasyBooks
    Participant

    Thank you!

    #1253187

    Paul R
    Moderator

    You’re welcome! 🙂