I am going by this tutorial ( https://redvinestudio.com/how-to-build-isotope-portfolio-in-your-wordpress-theme/ ), and when I am working on the part where the portfolio items are displayed as links, the url that the link leads to is being displayed above the item. Below is the prescribed code:
echo '<div class="all portfolio-item '. $tax .'">';
echo '<a href="'. the_permalink() .'" title="'. the_title_attribute() .'">';
echo '<div class="thumbnail">'. the_post_thumbnail('thumbnail') .'</div>';
echo '<h2>'. the_title() .'</h2>';
echo '</a>';
/*echo '<div>'. the_excerpt() .'</div>';*/
echo '</div>';
You can't use the_permalink()
within an echo
, because it echo
es data itself. Instead, you need to use get_permalink() . You also need to modify the_title_attribute()
to avoid a duplicated echo
there:
echo '<a href="'. get_permalink() .'" title="'. the_title_attribute( 'echo=0' ) .'">';
EDIT: You need to comb through your code to remove all instances of code that is echoing content within an echo
. This includes the_title()
, the_post_thumbnail()
, etc.
the_permalink() will always echo the URL of the object, which means you're telling it to echo twice. Change it to get_permalink() and it should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.