Archived topic
right above the sitebar 2 images made with NEXT and PREVIOUS
48 replies · Started by diedrich on November 23, 2020
Thanks Leo
just for clarity where do I paste this?
Hi there,
create a new Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
Add this code to the hook text field:
<?php
if ( is_attachment() ) {?>
<div class="attach-navigation">
<span class="prev"><?php previous_image_link( 'thumbnail' );?></span>
<span class="next"><?php next_image_link( 'thumbnail' );?></span>
</div>
<?php
}
?>
Check execute PHP.
Select the Hook: generate_before_right_sidebar_content
Set the Display Rules to Entire Site
Thank you David
No CSS code ?
If you can add the Hook then so i can see its outputting the next / previous images then ill take a look at the CSS required.
oeiiiiii . I did it ........, but I see nothing . also clear my cache WP-rOCKET
WHAT DO i WRONG ?
Greeting Diedrich
I am not seeing the code in the site.
Can you provide screenshots of the Hook Element and its display rules ?
Hi David
where can I drop the photos?
Can you check the execute PHP?
https://www.screencast.com/t/KlCV9KiI
hello, the beginning is there ....... :-) :-) :-) , I see 2 images on my attachemd page:
but the following is not yet correct:
1: he now randomly takes an image somewhere, he has to take the correct image, namely from an attachemd page the order of the attachement page
2: otherwise the text NEXT and PREVIOUS is missing
3: and the 2 images should remain fixed when scrolling
can you help me?
greeting diedrich
Try changing the PHP code to this:
<?php
if ( is_attachment() ) {?>
<div class="attach-navigation">
<span class="prev"><?php adjacent_image_link( false, 'thumbnail', 'Previous Link' );?></span>
<span class="next"><?php adjacent_image_link( true, 'thumbnail', 'Next Link' );?></span>
</div>
<?php
}
?>
Hi David, sorry this is no good
>>>>> I don't see any more pictures
>>>>> text on the image is also incorrect
>>>>> next is previous
>>>>> previous is next
>>>>>> which is very important: there is no order, so for example "next" it will not show the first next
cache is empty
You can put back the old code, below i have included that code with the Previous Link and Next Link labels. You can change the labels to whatever you want:
<?php
if ( is_attachment() ) {?>
<div class="attach-navigation">
<span class="prev"><?php previous_image_link( 'thumbnail', 'Previous Link' );?></span>
<span class="next"><?php next_image_link( 'thumbnail', 'Next Link' );?></span>
</div>
<?php
}
?>
But there is no way to change the order of them, they will simply display whatever attachment was registered before that one or after that one. Theres no control over that.
you say you can't set the order of next and previous? you can't do anything with the data that is mentioned everywhere?
i still don't see the image either
I have clear my cache
Greeting
Diedrich
Looking at the functions, it seems like you can choose text OR the image.. If you remove the text from those functions, the images should appear. Not sure what their thinking was behind this.. it may be possible to re-add the text using CSS, as adding the image in with the text would be much more complex.
The order itself is defined by WP as it's a core function.