如何提高WP程序发布文章的质量

来源:互联网 发布:android程序员的简历 编辑:程序博客网 时间:2024/05/22 10:35

如何提高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(); 
0 0