您的位置:首页 > 其它

如何提高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(); 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: