如何提高WP程序发布文章的质量
2014-03-12 10:23
323 查看
如何提高WP程序发布文章的质量
1. Add post formart support to your wordpress theme
// Hook into the 'after_setup_theme' action
add_action( 'after_setup_theme', 'coolwp_a' );
function coolwp_a() {
// Add theme support for Post Formats
$formats = array( 'status', 'quote', 'gallery', 'image', 'video', 'audio', 'link', 'aside', 'chat', );
add_theme_support( 'post-formats', $formats );
}
2. Terms of each post formart in wordpress
post-format-aside
post-format-audio
post-format-chat
post-format-gallery
post-format-image
post-format-link
post-format-status
post-format-quote
post-format-video
3.Query posts of someone post formart
Get a list of your post formart:
$my_formats = get_post_format_slugs();
foreach ( (array) $my_formats as $i => $format ) {
$my_formats[$i] = 'post-format-' . $format;
}
posts only in image formart:
$images = get_posts( array(
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-image' ),
'operator' => 'IN'
)
)
) );
posts not in image formart:
$no_images = get_posts( array(
'tax_query' => array(
array( 自吸磁力泵
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-image' ),
'operator' => 'NOT IN'
)
)
) );
Exclude posts in image and status:
$exclude_images_and_status = get_posts( array(
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-image', 'post-format-status' ),
'operator' => 'NOT IN',
)
)
) );
An example:http://www.hrbgaj.gov.cn/
$my_formats = get_post_format_slugs();
foreach ( (array) $my_formats as $i => $format ) {
$my_formats[$i] = 'post-format-' . $format;
}
$standard_posts = get_posts( array(
'tax_query' => array(
array( 自吸磁力泵
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => $my_formats,
'operator' => 'NOT IN'
)
)
) );
global $post;
foreach( (array) $standard_posts as $post ) {
setup_postdata( $post );
print '<div>';
the_title( '<h2>', '</h2>' );
the_content();
print '</div>';
}
wp_reset_postdata();
1. Add post formart support to your wordpress theme
// Hook into the 'after_setup_theme' action
add_action( 'after_setup_theme', 'coolwp_a' );
function coolwp_a() {
// Add theme support for Post Formats
$formats = array( 'status', 'quote', 'gallery', 'image', 'video', 'audio', 'link', 'aside', 'chat', );
add_theme_support( 'post-formats', $formats );
}
2. Terms of each post formart in wordpress
post-format-aside
post-format-audio
post-format-chat
post-format-gallery
post-format-image
post-format-link
post-format-status
post-format-quote
post-format-video
3.Query posts of someone post formart
Get a list of your post formart:
$my_formats = get_post_format_slugs();
foreach ( (array) $my_formats as $i => $format ) {
$my_formats[$i] = 'post-format-' . $format;
}
posts only in image formart:
$images = get_posts( array(
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-image' ),
'operator' => 'IN'
)
)
) );
posts not in image formart:
$no_images = get_posts( array(
'tax_query' => array(
array( 自吸磁力泵
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-image' ),
'operator' => 'NOT IN'
)
)
) );
Exclude posts in image and status:
$exclude_images_and_status = get_posts( array(
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-image', 'post-format-status' ),
'operator' => 'NOT IN',
)
)
) );
An example:http://www.hrbgaj.gov.cn/
$my_formats = get_post_format_slugs();
foreach ( (array) $my_formats as $i => $format ) {
$my_formats[$i] = 'post-format-' . $format;
}
$standard_posts = get_posts( array(
'tax_query' => array(
array( 自吸磁力泵
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => $my_formats,
'operator' => 'NOT IN'
)
)
) );
global $post;
foreach( (array) $standard_posts as $post ) {
setup_postdata( $post );
print '<div>';
the_title( '<h2>', '</h2>' );
the_content();
print '</div>';
}
wp_reset_postdata();
相关文章推荐
- 如何删除WP系统程序中标题重复的文章
- 如何抓取微信公共帐号发布的文章的阅读数和赞数
- 一堂如何提高代码质量的培训课
- 如何加快测试进度,提高测试质量--评审(其中的一个方法)
- Java程序员成长之路(如何提高Java程序性能?)
- 如何使用Android Studio提高App质量
- .net执行性能,Winform性能优化?如何提高.net程序性能
- WordPress教程:如何在发布文章前对内容进行预处理
- 织梦发布的文章如何批量替换文章"来源"和"作者"?
- 分享VS2010如何发布winform程序,附带access数据库
- 如何制定SEO文章发布模板?
- ios如何联机调试和发布程序
- 如何制定SEO文章发布模板?
- 如何使用live writer客户端来发布CSDN的博客文章?
- iPhone应用提交流程:如何将App程序发布到App Store?
- 如何写出很牛的代码,提高你的代码质量?
- 如何使用live writer客户端来发布CSDN的博客文章?
- 如何提高程序的执行效率
- 如何发布VC2005/VC2008编译的程序
- 一堂如何提高代码质量的培训课(转)