因此, 我正在制作一个wordpress主题, 并且在设置archive.php的样式, 希望你们中的一个可以帮助我解决我的问题。我对所有这些都是新手, 因此答案越彻底越好。我目前正在使用此:
<?php $the_query = new WP_Query( array('posts_per_page'=>1, 'cat'=>'current_page_category')); ?>
#1
你可以像这样获取当前的类别ID:
有关此内容的更多信息, 请参阅WP Codex。
<?php
$current = get_category(get_query_var('cat'));
$current_id = $current->term_id;
$args = array(
'posts_per_page' => 1, 'cat' => $current_id, );
$wp_query = new WP_Query($args);
?>
来源:
https://www.srcmini02.com/63649.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_41738.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57