This wpmudev post 总结了我对2014年的感受:
特色内容不支持自定义帖子类型–即使自定义帖子类型支持标签分类法,也只选择帖子
我添加了两个共享自定义分类法的CPT。我试着在没有任何运气的情况下标记它们,看看inc/featured-content.php
,js/slider.js
和functions.php
.
如何添加这些帖子类型,使其显示在主页的特色内容滑块中?
This wpmudev post 总结了我对2014年的感受:
特色内容不支持自定义帖子类型–即使自定义帖子类型支持标签分类法,也只选择帖子
我添加了两个共享自定义分类法的CPT。我试着在没有任何运气的情况下标记它们,看看inc/featured-content.php
,js/slider.js
和functions.php
.
如何添加这些帖子类型,使其显示在主页的特色内容滑块中?
twentyfourteen_get_featured_posts
过滤器:twentyfourteen_get_featured_posts
过滤器用于第214主题;-)特色内容是fetched 使用:
$featured_posts = twentyfourteen_get_featured_posts();
但该函数仅为一行:return apply_filters( \'twentyfourteen_get_featured_posts\', array() );
那么肉在哪里?我们在Featured_Content
类,从这个开始line:
add_filter( $filter, array( __CLASS__, \'get_featured_posts\' ) );
在哪里$filter
来自:$filter = $theme_support[0][\'featured_content_filter\'];
其中:$theme_support = get_theme_support( \'featured-content\' );
<小时>英寸functions.php
我们发现:// Add support for featured content.
add_theme_support( \'featured-content\', array(
\'featured_content_filter\' => \'twentyfourteen_get_featured_posts\',
\'max_posts\' => 6,
) );
因此,我们最终看到:$filter === \'twentyfourteen_get_featured_posts\';
示例:要覆盖默认的特色内容帖子,您可以尝试以下操作:add_filter( \'twentyfourteen_get_featured_posts\', function( $posts ){
// Modify this to your needs:
$posts = get_posts( array(
\'post_type\' => array( \'cpt1\', \'cpt2\' ),
\'posts_per_page\' => 6,
\'featured_tax\' => \'featured_term\'
) );
return $posts;
}, PHP_INT_MAX );
下一步是将其连接到主题定制器,并可能缓存它。希望您可以从这里继续旅程;-)
您好,我有一个生成错误的短代码。有人能帮忙吗?add_shortcode(\'do-action\', \'do_action_shortcode\'); function do_action_shortcode($atts, $content = \'\') { ob_start(); do_action($content); $out = ob_get_contents(); ob_end_clean(); return $
This wpmudev post 总结了我对2014年的感受:
特色内容不支持自定义帖子类型–即使自定义帖子类型支持标签分类法,也只选择帖子
我添加了两个共享自定义分类法的CPT。我试着在没有任何运气的情况下标记它们,看看inc/featured-content.php
,js/slider.js
和functions.php
.
如何添加这些帖子类型,使其显示在主页的特色内容滑块中?
twentyfourteen_get_featured_posts
过滤器:twentyfourteen_get_featured_posts
过滤器用于第214主题;-)特色内容是fetched 使用:
$featured_posts = twentyfourteen_get_featured_posts();
但该函数仅为一行:return apply_filters( \'twentyfourteen_get_featured_posts\', array() );
那么肉在哪里?我们在Featured_Content
类,从这个开始line:
add_filter( $filter, array( __CLASS__, \'get_featured_posts\' ) );
在哪里$filter
来自:$filter = $theme_support[0][\'featured_content_filter\'];
其中:$theme_support = get_theme_support( \'featured-content\' );
<小时>英寸functions.php
我们发现:// Add support for featured content.
add_theme_support( \'featured-content\', array(
\'featured_content_filter\' => \'twentyfourteen_get_featured_posts\',
\'max_posts\' => 6,
) );
因此,我们最终看到:$filter === \'twentyfourteen_get_featured_posts\';
示例:要覆盖默认的特色内容帖子,您可以尝试以下操作:add_filter( \'twentyfourteen_get_featured_posts\', function( $posts ){
// Modify this to your needs:
$posts = get_posts( array(
\'post_type\' => array( \'cpt1\', \'cpt2\' ),
\'posts_per_page\' => 6,
\'featured_tax\' => \'featured_term\'
) );
return $posts;
}, PHP_INT_MAX );
下一步是将其连接到主题定制器,并可能缓存它。希望您可以从这里继续旅程;-)
我在函数中不断遇到此代码的未定义索引错误。我做错了什么?function hire_more(){ $hire = $_GET[\'hire_more\']; write_log($hire); } add_action(\'wp_loaded\',\'hire_more\');