0

I am attempting to change what is currently PHP-generated text links into image links.

This is the navigation on my index page to show previous posts or next posts if there are some available, so it is not a static image link.

Here is the original code:

<div class="next"><?php previous_posts_link( __( '&#8249; Newer Posts', 'imbalance2' ) ); ?></div>
<div class="previous"><?php next_posts_link( __( 'Older Posts &#8250;', 'imbalance2' ) ); ?></div>

I want to change the arrows (&#8249 + &#8250) with the text into just png images I made.

Here was one of my attempts.

<div class="next"><?php previous_posts_link( __( <?php echo  "<img src="wp-content/images/srnewerposts.png"  /></a>"; ?> ) ); ?></div>
<div class="previous"><?php next_posts_link( __( <?php echo  "<img src="wp-content/images/srolderposts.png"  /></a>"; ?> ) ); ?></div>

This generates an error:

Parse error: syntax error, unexpected '<', expecting ')'

I originally tried just to put the file path without the php echo tag, but it did not expect the / at the beginning of my path.

I've made many searches, but was not able to find something that helps.

Pang
  • 9,564
  • 146
  • 81
  • 122

1 Answers1

1

Try this :

$srnewerposts = content_url().'/images/srnewerposts.png';
$srolderposts = content_url().'/images/srolderposts.png';
<div class="next"><?php previous_posts_link("<img src='".$srnewerposts."'  />"  ); ?></div>
<div class="previous"><?php next_posts_link("<img src='".$srolderposts."'  />" ); ?></div>
vrajesh
  • 2,935
  • 3
  • 25
  • 40
  • That's great, thanks! To get it to work I added a php tag around the first two lines with the variables. – user3221637 Dec 03 '16 at 14:04
  • "Try this" and code only answers are not good answers as they fail to explain what the problem was and how this resolves it. – John Conde Dec 05 '16 at 13:38
  • @JohnConde My answer need more information about problem and commitment.Thanks for your comment .I totally understand. your suggestion will execute in my next answer :). – vrajesh Dec 06 '16 at 04:57