Rob Erskine
Rob Erskine

Reputation: 927

obtaining page title from wordpress function previous_post_link()

I'm having a bit of trouble getting my previous_post_link and next_post_link's to have title attributes.

I'm passing them along like this:

<div class="previous <?php if(!get_previous_post()){ echo 'inactive'; }?>">
     <?php previous_post_link('%link', true); ?>
</div>              

<div class="next <?php if(!get_next_post()){ echo 'inactive'; }?>">                     
     <?php next_post_link('%link', true); ?>                
</div>

Optimally, I'd love to get this as an output:

<a href="previous/post/page.html" title="That posts title">previous post</a>

Is there a parameter that I'm missing? Or is something like this not achieveable?

edit: for clarification

Upvotes: 1

Views: 562

Answers (2)

Sufiyan Ghori
Sufiyan Ghori

Reputation: 18753

OK, then have a look at this one,

http://perishablepress.com/press/2006/04/23/wordpress-title-attributes/

and this one,

https://wordpress.stackexchange.com/questions/13044/how-can-i-add-title-attributes-to-next-and-previous-post-link-functions

These links has been found on google, and it exactly answers what you're asking , so its always better to do some search before raising it as a new question.

Upvotes: 0

Sufiyan Ghori
Sufiyan Ghori

Reputation: 18753

in wordpress posts_nav_link(), displays both the Previous and Next links, or if you want both previous and next post link seperately,

here is the code,

 <?php previous_post(); ?> 

it displays text "previous post:" as link along with post title.

without a post title,

 <?php previous_post('%','&laquo; Previous', 'no'); ?> 

To display text, like arrows («), at the beginning of the previous post link and at the end of the next post link so it looks like:

<?php previous_post('&laquo; &laquo; %', '', 'yes'); ?>
| <?php next_post('% &raquo; &raquo; ', '', 'yes'); ?>

Upvotes: 1

Related Questions