Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1131635
    Malte K
    Participant

    Hello I would like to add an extra Button to the native Page Navigation [all posts (just a link to a page) / next post / prev post]. Is there a simple function, which i can add in the function.php, which can do this?

    Best,

    Malte

    #1131655
    Christopher
    Moderator

    Hi there,

    Please add following code in child theme’s functions.php file :

    // Entry Navigation
    // =============================================================================
    
    if ( ! function_exists( 'x_entry_navigation' ) ) :
      function x_entry_navigation() {
    
      $stack = x_get_stack();
    
      if ( $stack == 'ethos' ) {
        $left_icon  = '<i class="x-icon-chevron-left" data-x-icon=""></i>';
        $right_icon = '<i class="x-icon-chevron-right" data-x-icon=""></i>';
      } else {
        $left_icon  = '<i class="x-icon-arrow-left" data-x-icon=""></i>';
        $right_icon = '<i class="x-icon-arrow-right" data-x-icon=""></i>';
      }
    
      $is_ltr    = ! is_rtl();
      $prev_post = get_adjacent_post( false, '', false );
      $next_post = get_adjacent_post( false, '', true );
      $prev_icon = ( $is_ltr ) ? $left_icon : $right_icon;
      $next_icon = ( $is_ltr ) ? $right_icon : $left_icon;
    
      ?>
    <div class="custom-btn">
    <?php echo do_shortcode('[x_button type="real" shape="square" size="mini" href="#example" title="Example"]Square Button[/x_button]'); ?> 
    </div>
      <div class="x-nav-articles">
    
        <?php if ( $prev_post ) : ?>
          <a href="<?php echo get_permalink( $prev_post ); ?>" title="<?php __( 'Previous Post', '__x__' ); ?>" class="prev">
            <?php echo $prev_icon; ?>
          </a>
        <?php endif; ?>
    
        <?php if ( $next_post ) : ?>
          <a href="<?php echo get_permalink( $next_post ); ?>" title="<?php __( 'Next Post', '__x__' ); ?>" class="next">
            <?php echo $next_icon; ?>
          </a>
        <?php endif; ?>
    
      </div>
    
      <?php
    
      }
    endif;

    Hope it helps.

    #1131684
    Malte K
    Participant

    I changed the Code to this, now it is working perfectly. For different costum post types different URLS and a thumbnail button. THX!

    // Entry Navigation
    // =============================================================================
    
    if ( ! function_exists( 'x_entry_navigation' ) ) :
      function x_entry_navigation() {
    
      $stack = x_get_stack();
    
      if ( $stack == 'ethos' ) {
        $left_icon  = '<i class="x-icon-chevron-left" data-x-icon=""></i>';
        $right_icon = '<i class="x-icon-chevron-right" data-x-icon=""></i>';
      } else {
        $left_icon  = '<i class="x-icon-arrow-left" data-x-icon=""></i>';
        $right_icon = '<i class="x-icon-arrow-right" data-x-icon=""></i>';
      }
    
      $is_ltr    = ! is_rtl();
      $prev_post = get_adjacent_post( false, '', false );
      $next_post = get_adjacent_post( false, '', true );
      $prev_icon = ( $is_ltr ) ? $left_icon : $right_icon;
      $next_icon = ( $is_ltr ) ? $right_icon : $left_icon;
    
    // Costum URL for Costum Post Type - Archive 
    if ( is_singular( 'ausstellung' ) ) {
      $url = 'http://maltekebbel.de/ausstellungen'; 
    }
    
    if ( is_singular( 'arbeit' ) ) {
      $url = 'http://maltekebbel.de/arbeiten'; 
    }
    
    if ( is_singular( 'post' ) ) {
      $url = 'http://maltekebbel.de/blog'; 
    }
    
      ?>
    
      <div class="x-nav-articles" style="width: 123px !important;">
      <?php /* Extra Button */ echo do_shortcode('<a href="'.$url.'" style="float:left; margin-right:6px !important;">[x_icon type="th"]</a>'); ?> 
        <?php if ( $prev_post ) : ?>
          <a href="<?php echo get_permalink( $prev_post ); ?>" title="<?php __( 'Previous Post', '__x__' ); ?>" class="prev">
            <?php echo $prev_icon; ?>
          </a>
        <?php endif; ?>
    
        <?php if ( $next_post ) : ?>
          <a href="<?php echo get_permalink( $next_post ); ?>" title="<?php __( 'Next Post', '__x__' ); ?>" class="next">
            <?php echo $next_icon; ?>
          </a>
        <?php endif; ?>
    
      </div>
    
      <?php
    
      }
    endif;
    #1131715
    Thai
    Moderator

    If you need anything else please let us know.

  • <script> jQuery(function($){ $("#no-reply-1131635 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>