如何使用类别插件来回显具有相同插件的页面内容

时间:2021-12-08 作者:Pete

我如何才能适应这类slug

<?php $term = get_queried_object(); echo $term->slug; ?>

进入此页面内容<?php $page = get_posts([ \'name\' => \'slug-goes-here\', \'post_type\' => \'page\' ]); if ( $page ){ echo $page[0]->post_content;} ?>

1 个回复
最合适的回答,由SO网友:Pete 整理而成

Worked it out...

<?php $term = get_queried_object(); ?>
<?php   
$page = get_posts([
    \'name\'      => $term->slug,
    \'post_type\' => \'page\'
]);
if ( $page ){ echo $page[0]->post_content; }    
?>