默认情况下post
类型,为什么has_archive
属性等于FALSE
?
$type_obj = get_post_type_object(\'post\');
var_dump($type_obj->has_archive); // FALSE
默认情况下post
类型,为什么has_archive
属性等于FALSE
?
$type_obj = get_post_type_object(\'post\');
var_dump($type_obj->has_archive); // FALSE
延迟回答。
<小时>has_archive
仅适用于rewrite
参数。
has_archive
设置为true
, 然后$archive_slug
将设置为rewrite[\'slug\']
论点如果那么arewrite[\'with_front\']
arg已设置,则此参数将被预先设置。然后将其结果添加为重写规则:add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", \'top\' );
如果feeds
设置为true,并且has_archive
此外,您还将获得提要的重写规则:add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . \'&feed=$matches[1]\', \'top\' );
add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . \'&feed=$matches[1]\', \'top\' );
同样的原则适用于rewrite[\'pages\']
:add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . \'&paged=$matches[1]\', \'top\' );
总结一下:如果你没有has_archive
设置为true
, 然后尝试为添加重写feeds
, pages
否则档案馆将以?
.我创建了一个主题,在每个页面上使用一个特色图像。在设置中,我将我的“帖子页面”设置为“新闻”。。。如何从“新闻”中获取要显示的特色图像?以下内容将显示“我的帖子”页面的id:<?php $page_for_posts = get_option( \'page_for_posts\' ); echo $page_for_posts; ?> 所以我想这会显示我帖子页面的特色图片:<?php $page_for_posts =