WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Next Link progression through categories slugs

[Resolved] Next Link progression through categories slugs

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author David Lingren
    Participant

    @dglingren

    Thanks for the good words and for posting a link to your site. I was able to get in and have a look, but I do not see next/prev links on the page I got to.

    It would be really helpful if you could post the source text of the page that generates the gallery so I could look at the [mla_gallery] shortcode(s) you have now. Is that possible?

    drewdrewthis
    Member

    @drewdrewthis

    Hi, I actually was able to figure out the next/prev.. I think! Now I’m working on getting it to give me the link back to gallery page. Getting the images to progress through the slugs instead of the ids is still giving me a hard time though!

    image.php page:

    <span><?php echo do_shortcode(‘[mla_gallery mla_output=”previous_link” mla_link_text=”← MLA Previous Image” attachment_category=”mla-sculpture” attachment_tag=”{+request:attachment_tag+}” id=”{+request:current_id+}” mla_caption=”{+title+}” mla_link_href=”{+site_url+}?p={+attachment_ID+}&attachment_tag={+request:attachment_tag+}”]’);?></span>
    <span><?php echo do_shortcode(‘[mla_gallery mla_output=”next_link” mla_link_text=”MLA Next Image → {+query:term_taxonomy_id+}” attachment_category=”mla-sculpture” attachment_tag=”{+request:attachment_tag+}” id=”{+request:current_id+}” mla_caption=”{+title+}” mla_link_href=”{+site_url+}?p={+attachment_ID+}&attachment_tag={+request:attachment_tag+}”]’);?></span>

    Gallery page code:

    [mla_gallery taxonomy=attachment_tag attachment_category=”mla-sculpture” attachment_tag=”{+request:term_id+}” mla_link_href=”{+site_url+}/?p={+attachment_ID+}&current_id={+attachment_ID+}&attachment_tag={+query:attachment_tag+}&group={+query:term_taxonomy_id+}” orderby=slug order=DESC columns=0 post_parent=current ]

    drewdrewthis
    Member

    @drewdrewthis

    A specific example is if you are on the attachment page for ‘Pietnascie’ (5th image in Sculpture), and you click the next image link, it will actually jump to “Ogromna (detail)” ( 7th image) instead of the 6th image. This is, I’m assuming, because it’s going in order of IDs.. I need it to maintain the order of the mla-gallery.

    drewdrewthis
    Member

    @drewdrewthis

    HA!! I did it. Slow and steady, I suppose. I’m still working on getting a correct short code that will print the tag name of the current image and link back to the tag gallery, if you happen to pop on here before I get it.

    Specifically:

    I want a link progression that goes:

    Sculpture Gallery –> 1990-1994 –> Image 1 –> Image 2 –> Image 3 –> 1990-1994

    Plugin Author David Lingren
    Participant

    @dglingren

    Congratulations on your progress (and on the site, which features beautiful work)!

    Since you are working in a WordPress template file (image.php) you have a lot of flexibility. To get the “tag name” of the current image you can try something like:

    if ( isset( $_REQUEST['attachment_tag'] ) {
        $term = get_term_by( 'slug', $_REQUEST['attachment_tag'], 'attachment_tag' );
        $term_name = $term->name;
    }

    To get the “Gallery” links at each end of the chain you can try something like:

    <span>
    <?php
    if ( isset( $_REQUEST['attachment_tag'] ) {
        $term = get_term_by( 'slug', $_REQUEST['attachment_tag'], 'attachment_tag' );
        $term_name = $term->name;
        $gallery_link = sprintf( '<a href="%1$s/sculpture/?term_id=%2$s">%3$s</a>',
            site_url(), $_REQUEST['attachment_tag'],  $term_name );
    } else {
        $gallery_link = sprintf( '<a href="%1$s/sculpture/">All</a>',
            site_url() );
    }
    
    $previous_link = do_shortcode('[mla_gallery mla_output="previous_link" mla_link_text="← MLA Previous Image" attachment_category="mla-sculpture" attachment_tag="{+request:attachment_tag+}" id="{+request:current_id+}" mla_caption="{+title+}" mla_link_href="{+site_url+}?p={+attachment_ID+}&attachment_tag={+request:attachment_tag+}"]');
    
    if ( empty( $previous_link ) ) {
        $previous_link = $gallery_link;
    }
    
    echo $previous_link;
    ?>
    </span>
    <span>
    <?php
    $next_link = do_shortcode('[mla_gallery mla_output="next_link" mla_link_text="MLA Next Image → {+query:term_taxonomy_id+}" attachment_category="mla-sculpture" attachment_tag="{+request:attachment_tag+}" id="{+request:current_id+}" mla_caption="{+title+}" mla_link_href="{+site_url+}?p={+attachment_ID+}&attachment_tag={+request:attachment_tag+}"]');
    
    if ( empty( $next_link ) ) {
        $next_link = $gallery_link;
    }
    
    echo $next_link;
    ?>
    </span>

    I haven’t actually tested the above code, but you can easily find and fix any errors I’ve made. Let me know how it goes.

    Plugin Author David Lingren
    Participant

    @dglingren

    I hope the above suggestions worked out and you were able to complete your pagination link work.

    I am marking this topic resolved, but please update it if you have any problems or further questions about the code. Thanks for your interest in the plugin.

    Thank you as well for the review you posted. Good reviews and positive feedback are great motivations to keep working on the plugin and supporting its users.

    drewdrewthis
    Member

    @drewdrewthis

    David –

    Thank you so much. I was able to get everything else to work, but getting the Next/Prev Back to Index links to work within the tags was really outside of the scope of the project. If the client requests I move forward with this, or I feel so inclined, I’ll dive back into and give it another go ’round. I really appreciate your help and quick replies! Again, great plugin!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Next Link progression through categories slugs’ is closed to new replies.