php - show custom fields data in next and previous link in wordpress


I am trying to show a advanced custom fields data in previous post link in wordpress. But The data is not showing also it breaks the html as well.

<div >
$prev_post = get_previous_post();

if($prev_post) {
  $prev_title = strip_tags(str_replace('"', '', $prev_post->post_title));
  echo "\t" . '<a rel="prev" href="' . get_permalink($prev_post->ID) . '" title="' . $prev_title. '" >

  <<< &quot;'. $prev_title . '&quot;

  <img src="'.the_field("girl_image").'" alt="'.the_title().'/>

  </a>' . "\n";

In this code the "girl_img" field contains the URL of an image. I want to show the image based on the URL. But it is showing the URL itself instead of showing the image.




Useget_field() instead ofthe_field().

get_field() = Returns the value of the specified field.

the_field() = Displays the value of the specified field. This function is the same asecho get_field($field_name);

Replacethe_field("girl_image") withget_field("girl_image")

People are also looking for solutions to the problem: Passing session to a PHP script called by the VLC plugin


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.