Title: Parse error using previous_posts_link()
Last modified: August 22, 2016

---

# Parse error using previous_posts_link()

 *  [jowell123](https://wordpress.org/support/users/jowell123/)
 * (@jowell123)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/parse-error-using-previous_posts_link/)
 * Hi,
 * this code works:
    `<?php next_posts_link('<img src="http://www.joelcormack.com/
   mxmg.com/wordpress/wp-content/themes/marinelogix-light-and-dark/images/next.png"/
   >'); ?>`
 * this code doesn’t:
    `<?php previous_posts_link('<img src="<?php bloginfo('template_directory');?
   >/images/previous.png" />'); ?>`
 * I’ve searched these forums but can’t seem to find a way of properly pulling images
   from within the next and previous posts links. Is there a way it can be done,
   without hard coding?
 * My text editor doesn’t like like the latter code either and says its a parse 
   error.
 * any help would be most appreciated.

Viewing 1 replies (of 1 total)

 *  [Richard Aber](https://wordpress.org/support/users/richaber/)
 * (@richaber)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/parse-error-using-previous_posts_link/#post-5384326)
 * You are including an opening and closing set of <?php ?> tags, within an already
   open set of <?php ?> tags. This is confusing the PHP interpreter and causing 
   it to choke.
 * What you are essentially trying to do is concatenate a string (the <img> string),
   for use with the previous_posts_link() function.
 * So this :
    ‘<img src=”<?php bloginfo(‘template_directory’); ?>/images/previous.
   png” />’
 * Should be something more like this :
    `'<img src="' . get_template_directory_uri().'/
   images/previous.png" />'`
 * Which would make your full previous_posts_link code look more like this :
    `<?
   php previous_posts_link('<img src="' . get_template_directory_uri() . '/images/
   previous.png" />'); ?>`
 * Or, if you prefer to be more verbose, for clarity, declare the string as a variable
   separately, and pass that variable into the function, like this :
 *     ```
       <?php
       $label = '<img src="' . get_template_directory_uri() . '/images/previous.png" />';
       previous_posts_link($label);
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Parse error using previous_posts_link()’ is closed to new replies.

## Tags

 * [next_posts_link](https://wordpress.org/support/topic-tag/next_posts_link/)
 * [parse-error](https://wordpress.org/support/topic-tag/parse-error/)
 * [previous_posts_link](https://wordpress.org/support/topic-tag/previous_posts_link/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Richard Aber](https://wordpress.org/support/users/richaber/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/parse-error-using-previous_posts_link/#post-5384326)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
