Php 如何在<;a href>;
我在将Wordpress归档页面转换为页面模板时遇到了两个问题Php 如何在<;a href>;,php,wordpress,Php,Wordpress,我在将Wordpress归档页面转换为页面模板时遇到了两个问题 <?php $args = array( 'post_type' => 'casestudies', 'posts_per_page' => 12 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); echo '<div class="casestudy">'.get_th
<?php $args = array( 'post_type' => 'casestudies', 'posts_per_page' => 12 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="casestudy">'.get_the_post_thumbnail( $post->ID, '180,180' ).'</div>';
在wordpress中,有两种类型的函数。一个是返回结果的,另一个是响应结果的 您正在使用
the_permalink()代码>已在回显其结果
您需要使用get_the_permalink()
因为您试图在模板中回显它。get_permalink为该a href工作,谢谢,但是我如何才能让php的标题()和php的回显get_post($post_id)->post_摘录显示在光标悬停处
如果您在循环中,此代码应该可以工作
WordPress中的方法get将只提供字符串
如何描述问题所在?当我添加“”行时,它只打印链接,不包装echo。get_permalink为a href工作,谢谢,但是我如何才能让php获得标题()和php echo get_post($post_id)->post_摘录显示在光标悬停处?再次,您需要确保使用返回的函数,不是回声。使用获取标题()代码>而不是标题()代码>。同样对于摘录,使用get_the_extract()代码>此代码有效:echo“”;谢谢你的帮助!没问题,很乐意帮忙!
'<a href="'.the_permalink().'" class="anchor-hover">';
'<span class="details"><div class="anchor-hover details-h3"><?php the_title(); ?></div>';
'<p class="desc"><?php echo get_post($post_id)->post_excerpt; ?></p></span></a>';
endwhile; ?>
<div class="clear"></div>
</div></div>
<a href="#" title="<?php echo get_the_title() . ' - ' . get_the_excerpt(); ?>">LINK</a>