pschena
Member
Posted 2 years ago #
Looking to hack the code of single.php so that I can add a link to the next story.
We currently use the nav-above/nav-below links in Sandbox to get from one story to the next. The client would like to have the first story link with different text from the headline.
Need to isolate the latest post and have a link like "Check out more news…"
Would like to leave all other posts as they currently are.
Site in question is: http://showfx.com.au/news/
Thanks in advance
pschena
Member
Posted 2 years ago #
For the more code savvy users, would it be possible to count the number of posts and return that variable for use in an IF statement?
Something like:
$MostRecent = HowManyPostsAreThere
if (is_post('$MostRecent')) echo (blah blah)
else
(do nothing)
Would something like this work or be possible?
Not sure of the actual code involved.
Any help?
pschena
Member
Posted 2 years ago #
No that won't work.
No relationship between number of posts and the postID apparently.
Keep trying.
pschena
Member
Posted 2 years ago #
So on further research
<?php $newest_post_id = $posts[0]->ID; ?>
does the job of identifying the most recent post.
With this pearl, can someone tell why this would not work.
<?php $newest_post_id = $posts[0]->ID; ?>
<?php if(the_ID == $newest_post_id) {
echo 'yes';
} else {
echo 'no';
?>
pschena
Member
Posted 2 years ago #
hmmm, not sure that it does.
I am trying to modify single.php and that example looks like it would work for the list of posts in my limited experience.
Thanks though!
apologies - I skimmed your OP and totally missed the point! :-\
themightymo
Member
Posted 1 year ago #
Did you find a solution to this problem?