Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1235223
    jonesy2367
    Participant

    Hi

    I’m just using the regular WordPress gallery – is it possible to add a next/previous link in the attachment pages?

    thanks

    #1235605
    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in! Because what you are trying to accomplish requires a template customization, we would like to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    After the child theme is set up, please add the following code in your child theme’s functions.php file

    // Add  Next and Previous buttons in the attachment page
    // =============================================================================
    add_action( 'x_after_the_content_end', 'add_next_prev_buttons' );
    function add_next_prev_buttons(){ ?>
     <?php if ( is_attachment() ) : ?>
      <nav id="image-navigation" class="navigation image-navigation">
          <div class="nav-links">
          <?php previous_image_link( false, '<div class="previous-image">' . __( '&laquo; Previous Image', '$text_domain' ) . '</div>' ); ?>
          <?php next_image_link( false, '<div class="next-image">' . __( 'Next Image &raquo;', '$text_domain' ) . '</div>' ); ?>
          </div><!-- .nav-links -->
      </nav><!-- #image-navigation -->
     <?php endif; ?>
    <?php } 
    // =============================================================================

    The code above will create a next and previous links at the button of the content area.

    Hope this helps. Please let us know how it goes.

    #1235731
    jonesy2367
    Participant
    This reply has been marked as private.
    #1235748
    Thai
    Moderator

    Hi There,

    Your website is password protected.

    Please provide us with your password so we can take a closer look.

    Thanks.

    #1235754
    jonesy2367
    Participant
    This reply has been marked as private.
    #1235756
    jonesy2367
    Participant
    This reply has been marked as private.
    #1236110
    Rad
    Moderator

    Hi there,

    Next and previous only works on post types, hence, the attachment type on this case. There is no way it can tell the order if it’s just about the images in the gallery.

    Thanks!

    #1236505
    jonesy2367
    Participant

    sorry, are you sure?

    …as (next_image_link) is in the WordPress codex so https://codex.wordpress.org/Function_Reference/next_image_link

    and it says Usage..
    Typically uses in attachment.php. In the WordPress default theme Twenty Eleven and Twenty Twelve, it is used in image.php.
    <?php next_image_link( $size, $text ); ?>

    as it seems nonsensical to have a gallery function where you can add next/previous links that actually bear no relevance to the gallery (and only scroll through the media library, which bears no relationship to the gallery)?

    #1236510
    Christian
    Moderator

    Hey there,

    Regretfully this isn’t a feature offered by X. It could be possible with custom development, but this would be outside the scope of support we can offer. You might want to contact our trusted partners who caters X setup and customization needs. Please see https://community.theme.co/custom-development/. Thanks for understanding. Take care!

    #1236549
    jonesy2367
    Participant

    yes it must be a wordpress glitch

    #1236560
    Christopher
    Moderator

    let us know if you have further question.

    #1236709
    jonesy2367
    Participant

    (i’ve just tested it with 2014 theme, which ships with next/previous links on the attachment page, and there’s no control over what appears on those links)

    #1236712
    Christian
    Moderator

    Thanks for sharing. If you need more in depth changes, you might want to contact our trusted partners who caters X setup and customization needs. Please see https://community.theme.co/custom-development/

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