WordPress相关文章缩略图可以工作,但永久链接错误

我试图在每个WP帖子下方显示4个相关帖子。缩略图可以正常工作, 可以拉入特征图像和标题, 但是永久链接不能。它以” http://example.com/original-post-name/ <?the_permalink();?> /”(添加空格)的形式出现, 可以单击, 但当然找不到内容。这个确切的代码可以在我的其他站点上正常工作, 但不能在新站点上工作。我敢肯定它会得到改进-WordPress主题是我的新手。

 <?php
 // Default arguments
  $args = array(
 'posts_per_page' => 4, 'post__not_in'   => array( get_the_ID() ), 'no_found_rows'  => true, );

$cats = wp_get_post_terms( get_the_ID(), 'category' ); 
$cats_ids = array();  
foreach( $cats as $wpex_related_cat ) {
$cats_ids[] = $wpex_related_cat->term_id; 
}
if ( ! empty( $cats_ids ) ) {
$args['category__in'] = $cats_ids;
}

// Query posts
$wpex_query = new wp_query( $args );

// Loop through posts
foreach( $wpex_query->posts as $post ) : setup_postdata( $post ); ?>

<!--<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 
'echo=0' ) ); ?>"><?php the_title(); ?></a>-->
<div class="relatedthumb">
<a rel="external" href="<?the_permalink()?>"><?php the_post_thumbnail(array(150, 100)); ?><br 
/>
<?php the_title(); ?>
</a>
</div>

<?php
// End loop
endforeach;

// Reset post data
wp_reset_postdata(); ?>

不好意思, 如果以前有人问过-我已经尝试搜索, 希望这是一个简单的解决方案。谢谢!


#1


你使用了错误的php开头标签

<a rel="external" href="<?php the_permalink(); ?>">

所以这是一个错字

来源:

https://www.srcmini02.com/64473.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37450.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?