Thanks for your updates and for the link to a sample page.
Removing the two original lines is probably fine, but it depends on knowing all of the ways the Media/Attachment page can be reached on your site. The safest approach would be to test for the presence of the attachment_category
argument and use MLA navigation only when it’s present.
I also noticed that your gallery is sorted by date in descending order but there are no orderby=date order=desc
parameters in the pagination shortcodes. You should make sure the sorting of the gallery and the pagination shortcodes is the same.
Here is an updated example that contains both of the above suggestions:
<nav id="image-navigation" class="navigation" role="navigation">
<?php if ( isset( $_REQUEST['attachment_category'] ) ): ?>
<span class="previous-image"><?php echo do_shortcode('[mla_gallery mla_output="previous_link,wrap" mla_link_text="← Previous Image" attachment_category="{+request:attachment_category+}" orderby=date order=desc id="{+request:current_id+}" mla_rollover_text="{+title+}" mla_link_href="{+pagelink_url+}?current_id={+attachment_ID+}&attachment_category={+query:attachment_category+}"]' ); ?></span>
<span class="next-image"><?php echo do_shortcode('[mla_gallery mla_output="next_link,wrap" mla_link_text="Next Image →" attachment_category="{+request:attachment_category+}" orderby=date order=desc id="{+request:current_id+}" mla_rollover_text="{+title+}" mla_link_href="{+pagelink_url+}?current_id={+attachment_ID+}&attachment_category={+query:attachment_category+}"]' ); ?></span>
<?php else: ?>
<span class="previous-image"><?php previous_image_link( false, __( '← Previous' , 'customizr' ) ); ?></span>
<span class="next-image"><?php next_image_link( false, __( 'Next →' , 'customizr' ) ); ?></span>
<?php endif; ?>
</nav><!-- //#image-navigation -->
You wrote “sometimes, instead of text hyperlink, a thumbnail comes up“, with an example link. Very interesting! It looks like, on your site, unattached images are generating bad links. If you go to the “Tall Problems” gallery and hover over the “Beam Me Up” thumbnail the link looks like:
https://tall.life/a-new-old-house-for-tall-people/img_1774/?current_id=2281&attachment_category=tall-problems
If you hover over the “Skydiving While Tall” link you will see:
https://tall.life/?attachment_id=2514?current_id=2514&attachment_category=tall-problems
That link works, but if you click on the thumbnail for “The Social Slouch” you get a page not found and a “web page error”.
MLA uses a WordPress function, wp_get_attachment_link()
to get these links, and the problem lies somewhere in the WordPress code or in filterers used by your theme or another plugin. I have not been able to reproduce the problem on my own test site.
Can you go to the Settings/Permalinks admin submenu and tell me what your settings are? Are you using other plugins for lightbox or other image features?
You can also try adding size=none
to your pagination shortcodes. That may replace the thumbnail with the image title and would give me additional information. You could also try attaching the problem images to a post or page to see if that’s the root cause.
Without admin access to your site That’s the best I can suggest at this point.
You wrote “there is a lot of white space above the nav hyperlinks“. There are styles in your theme’s CSS files that add margins around the horizontal line and the pagination links. You can see if editing the theme or the CSS files can reduce them.