Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在<;a href>;_Php_Wordpress - Fatal编程技术网

Php 如何在<;a href>;

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

我在将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_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>