2015-07-21 76 views
1

I am going by this tutorial (https://redvinestudio.com/how-to-build-isotope-portfolio-in-your-wordpress-theme/),並且當我正在處理組合項目顯示爲鏈接的部分時,鏈接導致的URL將顯示在項目上方。下面是規定代碼:我的php echo聲明爲<a href="#"> is making the url visible

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>'; 

回答

1

您不能在echo內使用the_permalink(),因爲它echo ES數據本身。相反,您需要使用get_permalink()。您還需要修改the_title_attribute()避免重複echo有:

echo '<a href="'. get_permalink() .'" title="'. the_title_attribute('echo=0') .'">'; 

編輯:您需要通過您的代碼梳理來移除呼應的echo中的內容的代碼,所有實例。這包括the_title(),the_post_thumbnail()

+0

謝謝!像魅力一樣工作!同樣在提出這個問題之後,我注意到了the_title()部分的問題。將它改爲get_the_title()完成了這項工作!再次感謝! –

0

the_permalink()將始終回顯對象的URL,這意味着您要告訴它回聲兩次。將其更改爲get_permalink(),它應該可以工作。