post format分类法:
post format是默认分类法,注册于:
register_taxonomy( \'post_format\', \'post\', array(
\'public\' => true,
\'hierarchical\' => false,
\'labels\' => array(
\'name\' => _x( \'Format\', \'post format\' ),
\'singular_name\' => _x( \'Format\', \'post format\' ),
),
\'query_var\' => true,
\'rewrite\' => $rewrite[\'post_format\'],
\'show_ui\' => false,
\'_builtin\' => true,
\'show_in_nav_menus\' => current_theme_supports( \'post-formats\' ),
) );
在哪里
$rewrite[\'post_format\'] = $post_format_base ? array( \'slug\' => $post_format_base ):false;
以及
$post_format_base = apply_filters( \'post_format_rewrite_base\', \'type\' );
注意,分类法slug是
post_format
重写段塞是
type
.
帖子格式术语:
我们可以从
get_post_format_strings()
功能:
/**
* Returns an array of post format slugs to their translated and pretty display versions
*
* @since 3.1.0
*
* @return array The array of translated post format names.
*/
function get_post_format_strings() {
$strings = array(
\'standard\' => _x( \'Standard\', \'Post format\' ), // Special case. any value that evals to false will be considered standard
\'aside\' => _x( \'Aside\', \'Post format\' ),
\'chat\' => _x( \'Chat\', \'Post format\' ),
\'gallery\' => _x( \'Gallery\', \'Post format\' ),
\'link\' => _x( \'Link\', \'Post format\' ),
\'image\' => _x( \'Image\', \'Post format\' ),
\'quote\' => _x( \'Quote\', \'Post format\' ),
\'status\' => _x( \'Status\', \'Post format\' ),
\'video\' => _x( \'Video\', \'Post format\' ),
\'audio\' => _x( \'Audio\', \'Post format\' ),
);
return $strings;
}
这些条款都有漏洞
post-format-{$format}
哪里
$format
可以是以下内容之一:
aside, chat, gallery, link, image, quote, status, video, audio
在哪里
standard
不包括在内。
post format重写规则:
这里可以看到相应生成的重写规则:
根据Monkeyman重写分析器。
post格式公共查询:
因此,我们可以使用以下公共查询:
http://example.tld/type/post-format-aside/
http://example.tld/type/post-format-chat/
http://example.tld/type/post-format-gallery/
http://example.tld/type/post-format-link/
http://example.tld/type/post-format-image/
http://example.tld/type/post-format-quote/
http://example.tld/type/post-format-status/
http://example.tld/type/post-format-video/
http://example.tld/type/post-format-audio/
以给定的帖子格式显示所有帖子。
最新消息:ToddBenrud说他设法得到:
http://example.tld/type/image/
工作。
原因如下request
过滤器:
/**
* Filters the request to allow for the format prefix.
*
* @access private
* @since 3.1.0
*/
function _post_format_request( $qvs ) {
if ( ! isset( $qvs[\'post_format\'] ) )
return $qvs;
$slugs = get_post_format_slugs();
if ( isset( $slugs[ $qvs[\'post_format\'] ] ) )
$qvs[\'post_format\'] = \'post-format-\' . $slugs[ $qvs[\'post_format\'] ];
$tax = get_taxonomy( \'post_format\' );
if ( ! is_admin() )
$qvs[\'post_type\'] = $tax->object_type;
return $qvs;
}
add_filter( \'request\', \'_post_format_request\' );
这意味着带有查询变量的请求:
Array
(
[post_format] => image
)
已修改为正确的术语名称:
Array
(
[post_format] => post-format-image
[post_type] => Array
(
[0] => post
)
)
因此,我们还可以使用:
http://example.tld/type/aside/
http://example.tld/type/chat/
http://example.tld/type/gallery/
http://example.tld/type/link/
http://example.tld/type/image/
http://example.tld/type/quote/
http://example.tld/type/status/
http://example.tld/type/video/
http://example.tld/type/audio/