Search results for: “feed”

  • [WordPress] Reference วิธีการใช้งาน WP_Query

    [WordPress] Reference วิธีการใช้งาน WP_Query

    ในการ query เพื่อนำข้อมูลออกมาใช้งานใน WordPress นั้น มีอยู่หลายวิธี 1 ในนั้นก็คือ WP_Query ซึ่งวิธีการใช้งาน WP_Query นั้น ในเว็บของ WordPress เองก็มีอธิบายการใช้งานไว้แล้วครับ

    แต่ในเว็บ WordPress เองอธิบายไว้ซะละเอียดเกิน จนอาจจะยาวเกินไปที่เราจะทำการค้นหามาใช้งาน จนผมไปเจอใน Github คุณ Mark Luetke ได้ทำ Reference สำหรับใช้งาน WP_Query ไว้แบบนี้ครับ

    วิธีการใช้งาน WP_Query

    <?php
    /**
    * WordPress Query Comprehensive Reference
    * Compiled by luetkemj – luetkemj.com
    *
    * CODEX: https://codex.wordpress.org/Class_Reference/WP_Query
    * Source: https://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
    */
    
    $args = array(
        //////Author Parameters – Show posts associated with certain author.
        'author' => 1,2,3, //(int) – use author id [use minus (-) to exclude authors by ID ex. 'author' => -1,-2,-3,]
        'author_name' => 'luetkemj', //(string) – use 'user_nicename' (NOT name)
    
        //////Category Parameters – Show posts associated with certain categories.
        'cat' => 5,//(int) – use category id.
        'category_name' => 'staff', 'news', //(string) – use category slug (NOT name).
        'category__and' => array( 2, 6 ), //(array) – use category id.
        'category__in' => array( 2, 6 ), //(array) – use category id.
        'category__not_in' => array( 2, 6 ), //(array) – use category id.
    
        //////Tag Parameters – Show posts associated with certain tags.
        'tag' => 'cooking', //(string) – use tag slug.
        'tag_id' => 5, //(int) – use tag id.
        'tag__and' => array( 2, 6), //(array) – use tag ids.
        'tag__in' => array( 2, 6), //(array) – use tag ids.
        'tag__not_in' => array( 2, 6), //(array) – use tag ids.
        'tag_slug__and' => array( 2, 6), //(array) – use tag slugs.
        'tag_slug__in' => array( 2, 6), //(array) – use tag slugs.
    
        //////Taxonomy Parameters – Show posts associated with certain taxonomy.
        //Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
        //This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
        'tax_query' => array( //(array) – use taxonomy parameters (available with Version 3.1).
        'relation' => 'AND', //(string) – Possible values are 'AND' or 'OR' and is the equivalent of ruuning a JOIN for each taxonomy
            array(
                'taxonomy' => 'color', //(string) – Taxonomy.
                'field' => 'slug', //(string) – Select taxonomy term by ('id' or 'slug')
                'terms' => array( 'red', 'blue' ), //(int/string/array) – Taxonomy term(s).
                'include_children' => true, //(bool) – Whether or not to include children for hierarchical taxonomies. Defaults to true.
                'operator' => 'IN' //(string) – Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
            ),
            array(
                'taxonomy' => 'actor',
                'field' => 'id',
                'terms' => array( 103, 115, 206 ),
                'include_children' => false,
                'operator' => 'NOT IN'
            )
        ),
    
        //////Post & Page Parameters – Display content based on post and page parameters.
        'p' => 1, //(int) – use post id.
        'name' => 'hello-world', //(string) – use post slug.
        'page_id' => 1, //(int) – use page id.
        'pagename' => 'sample-page', //(string) – use page slug.
        'pagename' => 'contact_us/canada', //(string) – Display child page using the slug of the parent and the child page, separated ba slash
        'post_parent' => 1, //(int) – use page id. Return just the child Pages.
        'post__in' => array(1,2,3), //(array) – use post ids. Specify posts to retrieve.
        'post__not_in' => array(1,2,3), //(array) – use post ids. Specify post NOT to retrieve.
        //NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query
    
        //////Type & Status Parameters – Show posts associated with certain type or status.
        'post_type' => array( //(string / array) – use post types. Retrieves posts by Post Types, default value is 'post';
            'post', // – a post.
            'page', // – a page.
            'revision', // – a revision.
            'attachment', // – an attachment. The default WP_Query sets 'post_status'=>'published', but atchments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
            'any', // – retrieves any type except revisions and types with 'exclude_from_search' set to true.
            'my-post-type' // – Custom Post Types (e.g. movies)
        ),
        'post_status' => array( //(string / array) – use post status. Retrieves posts by Post Status, default value i'publish'.
            'publish', // – a published post or page.
            'pending', // – post is pending review.
            'draft', // – a post in draft status.
            'auto-draft' // – a newly created post, with no content.
            'future' // – a post to publish in the future.
            'private' // – not visible to users who are not logged in.
            'inherit' // – a revision. see get_children.
            'trash' // – post is in trashbin (available with Version 2.9).
            'any' // – retrieves any status except those from post types with 'exclude_from_search' set to true.
        ),
    
        //////Pagination Parameters
        'posts_per_page' => 10, //(int) – number of post to show per page (available with Version 2.1). Use 'posts_per_page'=1 to show all posts. Note if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. Treimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
        'posts_per_archive_page' => 10, //(int) – number of posts to show per page – on archive pages only. Over-rides showposts anposts_per_page on pages where is_archive() or is_search() would be true
        'nopaging' => false, //(bool) – show all posts or use pagination. Default value is 'false', use paging.
        'paged' => get_query_var('page'), //(int) – number of page. Show the posts that would normally show up just on page X when usinthe “Older Entries” link.
        //NOTE: You should set get_query_var( 'page' ); if you want your query to work with pagination. Since WordPress 3.0.2, you dget_query_var( 'page' ) instead of get_query_var( 'paged' ). The pagination parameter 'paged' for WP_Query() remains the same.
    
        //////Offset Parameter
        'offset' => 3, //(int) – number of post to displace or pass over.
    
        //////Order & Orderby Parameters – Sort retrieved posts.
        'order' => 'DESC', //(string) – Designates the ascending or descending order of the 'orderby' parameter. Defaultto 'DESC'.
        //Possible Values:
        //'ASC' – ascending order from lowest to highest values (1, 2, 3; a, b, c).
        //'DESC' – descending order from highest to lowest values (3, 2, 1; c, b, a).
        'orderby' => 'date', //(string) – Sort retrieved posts by parameter. Defaults to 'date'.
        //Possible Values://
        //'none' – No order (available with Version 2.8).
        //'ID' – Order by post id. Note the captialization.
        //'author' – Order by author.
        //'title' – Order by title.
        //'date' – Order by date.
        //'modified' – Order by last modified date.
        //'parent' – Order by post/page parent id.
        //'rand' – Random order.
        //'comment_count' – Order by number of comments (available with Version 2.9).
        //'menu_order' – Order by Page Order. Used most often for Pages (Order field in the EdiPage Attributes box) and for Attachments (the integer fields in the Insert / Upload MediGallery dialog), but could be used for any post type with distinct 'menu_order' values (theall default to 0).
        //'meta_value' – Note that a 'meta_key=keyname' must also be present in the query. Note alsthat the sorting will be alphabetical which is fine for strings (i.e. words), but can bunexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as yomight naturally expect).
        //'meta_value_num' – Order by numeric meta value (available with Version 2.8). Also notthat a 'meta_key=keyname' must also be present in the query. This value allows for numericasorting as noted above in 'meta_value'.
    
        //////Sticky Post Parameters – Show Sticky Posts or ignore them.
        'ignore_sticky_posts' => false, //(bool) – ignore sticky posts or not. Default value is false, don't ignore. Ignore/excludsticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order othat list of posts returned.
        //NOTE: For more info on sticky post queries see: https://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters
    
        //////Time Parameters – Show posts associated with a certain time period.
        'year' => 2012, //(int) – 4 digit year (e.g. 2011).
        'monthnum' => 3, //(int) – Month number (from 1 to 12).
        'w' => 25, //(int) – Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependenon the “start_of_week” option.
        'day' => 17, //(int) – Day of the month (from 1 to 31).
        'hour' => 13, //(int) – Hour (from 0 to 23).
        'minute' => 19, //(int) – Minute (from 0 to 60).
        'second' => 30, //(int) – Second (0 to 60).
    
        //////Custom Field Parameters – Show posts associated with a certain custom field.
        'meta_key' => 'key', //(string) – Custom field key.
        'meta_value' => 'value', //(string) – Custom field value.
        'meta_value_num' => 10, //(number) – Custom field value.
        'meta_compare' => '=', //(string) – Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or ='. Default value is '='.
        'meta_query' => array( //(array) – Custom field parameters (available with Version 3.1).
            array(
                'key' => 'color', //(string) – Custom field key.
                'value' => 'blue' //(string/array) – Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
                'type' => 'CHAR', //(string) – Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.
                'compare' => '=' //(string) – Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
            ),
            array(
                'key' => 'price',
                'value' => array( 1,200 ),
                'compare' => 'NOT LIKE'
            )
        ),
        //////Permission Parameters – Display published posts, as well as private posts, if the user has the appropriate capability:
        'perm' => 'readable' //(string) Possible values are 'readable', 'editable' (possible more ie all capabilitiealthough I have not tested)
    
        ////Parameters relating to caching
        'no_found_rows' => false, //(bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order timplement pagination. Even when you don't need pagination at all. By Setting this parameter to true you are telling wordPress not tcount the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more informatiosee: https://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions
        'cache_results' => true, //(bool) Default is true
        'update_post_term_cache' => true, //(bool) Default is true
        'update_post_meta_cache' => true //(bool) Default is true
        //NOTE Caching is a good thing. Setting these to false is generally not advised. For more info on usage see: https://codex.wordpresorg/Class_Reference/WP_Query#Permission_Parameters
    
        //////Post Field Parameters
        //Not sure what these do. For more info see: https://codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters
    
        //////Filters
        //For more information on available Filters see: https://codex.wordpress.org/Class_Reference/WP_Query#Filters
    );
    
    $the_query = new WP_Query( $args );
    
    // The Loop
    if ( $the_query->have_posts() ) :
        while ( $the_query->have_posts() ) : $the_query->the_post();
            // Do Stuff
        endwhile;
    endif;
    
    // Reset Post Data
    wp_reset_postdata();
    
    ?>

    หรือไปดูใน Github : WordPress Query Comprehensive Reference

  • [WordPress] ผนึกกำลัง Facebook, Twitter และ Google+

    [WordPress] ผนึกกำลัง Facebook, Twitter และ Google+

    ตอนนี้อะไรที่เป็น Social Network ช่วยให้เว็บของเรามีการประชาสัมพันธ์ออกไปได้ง่ายกว่าแต่ก่อน ซึ่งตัว WordPress เองก็มี Plugin อยู่หลาย ๆ ตัวที่ใช้สำหรับที่จะผนึกกำลัง WordPress ของเรากับบรรดา Social Network ต่าง ๆ แต่ครั้งนี้ไม่ได้มาแนะนำ Plugin นะครับ แต่เราจะมาเขียนการเชื่อมต่อ ๆ ต่างเองครับ ^^

    Facebook Comment

    เดี๋ยวนี้คนเราก็ Sign in facebook ไว้ตลอดอยู่แล้ว เลยเป็นเรื่องง่ายที่จะใช้ Facebook Comment แทนที่ WordPress Comment ที่เราใช้งานอยู่

    นอกเรื่องนิดนึง เรายังมีระบบ Comment แบบอื่นที่ใช้แทนที่ตัว WordPress Comment ได้ อย่างเช่น IntenseDebate หรือ Disqus ซึ่งทั้งสองตัวก็มี Plugin ที่ใช้งานกับ WordPress โดยเป็น IntenseDebate Comments และ Disqus Comment System

    ซึ่งจริง ๆ แล้วตัว Facebook Comment นั่นก็มี Plugin สำหรับ WordPress ไว้อยู่เหมือนกัน ก็คือ Facebook Comments for WordPress แต่ไม่รู้เหมือนกัน ว่าทำไมบางทีบางคนที่ติดตั้งก็ใช้งานมันไม่ได้ ดังนั้นก็ตัดปัญหาโดยไปจัดการเขียนมันเองแล้วกัน

    สร้าง Facebook Application

    ก่อนจะติดตั้ง Facebook Comment ลงในเว็บของเรา ให้เราไปสร้าง Facebook Application ก่อน ไปที่ Facebook Application กดที่ “+ Create New App” จะปรากฎแบบนี้ ก็กรอกข้อมูลลงไป

    [Wordpress] ผนึกกำลัง Facebook, Twitter และ Google+ [1]

    หลังจากที่สร้างเสร็จแล้ว ก็จะได้ Application มาประมาณนี้ครับ

    [Wordpress] ผนึกกำลัง Facebook, Twitter และ Google+ [5]

    ติดตั้ง Facebook Comment ลงในเว็บของเรา

    ไปเอา Code จากที่ Facebook Comments plugin page กรอกข้อมูลของตัว Facebook Comment ลงไป

    [Wordpress] ผนึกกำลัง Facebook, Twitter และ Google+ [6]

    กด Get Code เราก็จะได้ส่วนของ Code ที่เราจะนำไปแปะในเว็บของเรา อย่าลืมเลือก Application ให้ตรงกับที่เราสร้างขึ้นมาด้วยนะครับ

    [Wordpress] ผนึกกำลัง Facebook, Twitter และ Google+ [7]

    คราวนี้เราไปแก้ไขตัว header.php โดยนำ code ในส่วนหัวข้อที่ 1 ไปวางแปะหลังจาก tag body

    [php]
    <div id="fb-root"></div>
    <script>(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=เลขที่ Application ID ของเรา";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, ‘script’, ‘facebook-jssdk’));</script>
    [/php]

    หลังจากนั้นเราจะนำส่วนหัวข้อที่ 2 ไปแทนที่ส่วนของ WordPress Comment แต่อย่าลืมเปลี่ยนในส่วนของหัวข้อ data-href ให้เป็น <?php the_permalink(); ?> ด้วยนะครับ เพื่อที่เราจะแยก Comment ในแต่ละหน้าออกจากกัน

    [php]
    <div class="fb-comments" data-href="<?php the_permalink(); ?>" data-num-posts="10" data-width="870"></div>
    [/php]

    แล้วส่วนนี้จะไปวางแปะที่ไหนเหรอ ก็ให้ไปที่ comments.php แล้วนำ code นี้ไปวางแปะแทนที่ทั้งหมดไปเลย หรือจะเขียนเงื่อนไขในการแสดงก็ตามใจแต่เราจะปรับแต่งเลยครับ ซึ่งเราสามารถไปดูรวม Comment ในเว็บเราได้ที่ Comment Moderation tool

    ดึง Latest Tweet ของเรามาโชว์

    โดยเราจะดึงตัว RSS ของตัว Twitter มาใช้ ซึ่งตัว RSS ที่เราจะใช้ก็คือ

    https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=xxxxx

    ตัว xxxxx นั้นก็ให้เราใส่ชื่อลงไป เช่นของผม @Rabbitinblack ก็ใส่เป็น

    https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=rabbitinblack

    ส่วน Code ที่เราจะนำไปใช้ก็มาจาก CSS Tricks โดยปรับมาใช้แบบนี้ครับ

    [php]
    <?php
    include_once(ABSPATH . WPINC . ‘/feed.php’);
    $rss = fetch_feed(‘https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=rabbitinblack’);
    $maxitems = $rss->get_item_quantity(3);
    $rss_items = $rss->get_items(0, $maxitems);
    ?>
    <ul>
    <?php if ($maxitems == 0) echo ‘<li>No items.</li>’;
    else
    // Loop through each feed item and display each item as a hyperlink.
    foreach ( $rss_items as $item ) : ?>
    <li><a href='<?php echo $item->get_permalink(); ?>’><?php echo $item->get_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    [/php]

    จากที่ผมทดลองดูตัว get_item_quantity จะได้สูงสุดที่ 20 นะครับ ที่เหลือจะเพิ่มเติม code หรือจะนำไปวางไว้ตรงไหนก็แล้วแต่เราเลยครับ

    ดึง Tweet ที่เรา Favorite ไว้

    ถ้าตามไปดูที่เว็บ CSS Tricks จะเห็นว่าเค้าดึงเป็น Tweet ที่ Favorite ไว้ ดังนั้นเราจึงทราบว่า ต้องใช้ RSS ที่ตัวไหน

    https://twitter.com/favorites/xxxxx.rss

    เช่นกันในส่วนของ xxxxx ก็ให้เป็นชื่อแทน

    https://twitter.com/favorites/rabbitinblack.rss

    ใช้ Official Twitter Widget

    เราสามารถสร้าง Twitter Widget ได้ง่าย ๆ โดยไปที่ official Twitter profile widget

    [WordPress] ผนึกกำลัง Facebook, Twitter และ Google+ [9]

    และหลังจากที่ปรับแต่งค่าต่าง ๆ เสร็จแล้ว ก็นำ Code ไปใช้งานได้แล้วครับ วิธีที่ง่ายที่สุดก็คือในส่วนของหลังบ้าน WordPress ของเรา เข้าไปที่

    Appearance => Widgets

    แล้วก็เพิ่มตัว Text Widget ลงไป แล้วในช่องที่ให้กรอกข้อความ ก็แปะ Code ที่ได้มาจากตัว Official Twitter Widget มาแปะก็เสร็จแล้วครับ

    แต่ Plugin สำหรับ Twitter ก็มีนะ

    แน่นอนครับ สำหรับ WordPress ที่มี Plugin ให้เราเลือกเยอะแยะมากมายอยู่แล้ว จะไม่มี Plugin สำหรับตัว Twitter Widget ก็ยังไงอยู่

    เพิ่มปุ่ม Share ไปยัง Facebook, Twitter และ Google+

    [WordPress] ผนึกกำลัง Facebook, Twitter และ Google+ [10]

    เรามาดูกันทีละตัวเลยแล้วกันนะครับ โดย Code เราก็ต้องมีการปรับเปลี่ยนเพื่อให้ใช้ในทุกจุด

    Facebook

    สำหรับตัว Facebook Like Button นั้น เมื่อเราเข้าไปปรับแต่งค่าต่าง ๆ เพื่อนำมาใช้งานในเว็บเราแล้ว

    [Wordpress] ผนึกกำลัง Facebook, Twitter และ Google+ [11]

    โดย Code ที่ได้ในส่วนที่ 1 จะเหมือนกับที่เราได้ตอนทำ Facebook Comment ดังนั้นถ้าเราเคยแปะ Code ในส่วนที่ 1 ในส่วนของ header.php ด้านล่างของ tag body ไปแล้ว ก็ไม่ต้องแปะซ้ำ

    [Wordpress] ผนึกกำลัง Facebook, Twitter และ Google+ [12]

    แต่ในส่วนที่ 2 นั้น จะมีการเพิ่ม href="<?php the_permalink(); ?>" ลงไปเพิ่มเติมจาก

    [php]
    <div class="fb-like" data-href="https://rabbitinblack.com" data-send="false" data-layout="button_count" data-width="55" data-show-faces="false"></div>
    [/php]

    เป็น

    [php]
    <div class="fb-like" data-href="https://rabbitinblack.com" href="<?php the_permalink(); ?>" data-send="false" data-layout="box_count" data-width="55" data-show-faces="false"></div>
    [/php]

    Twitter

    สำหรับ Twitter Button นั้น เลือกที่ Share a link เพื่อสร้างปุ่มขึ้นมา

    [Wordpress] ผนึกกำลัง Facebook, Twitter และ Google+ [13]

    ซึ่ง Code ที่ได้มาเป็นแบบนี้ครับ

    [php]
    <a href="https://twitter.com/share" class="twitter-share-button" data-via="Rabbitinblack">Tweet</a>
    <script>
    !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>
    [/php]

    โดยเราจะเพิ่มส่วนของ data-text="<?php the_title(); ?>" และ data-url="<?php the_permalink(); ?>" แต่ถ้าอยากได้ปุ่มแบบมีการนับในแนวตั้งก็ให้ใส่ data-count="vertical" ลงไปด้วย

    [php]
    <a href="https://twitter.com/share" class="twitter-share-button" data-via="Rabbitinblack" data-count="vertical" data-text="<?php the_title(); ?>" data-url="<?php the_permalink(); ?>">Tweet</a>
    <script>
    !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>
    [/php]

    ซึ่งเราสามารถหาข้อมูลของ Tweet Button ได้เพิ่มที่ official Twitter button documentation page

    Google+

    และสุดท้ายกับปุ่ม +1 ของ Google+ นั้น เมื่อเราปรับแต่งรูปแบบของปุ่ม +1 แล้ว

    [Wordpress] ผนึกกำลัง Facebook, Twitter และ Google+ [14]

    Code ที่ได้มานั้น

    [php]
    <!– Place this tag where you want the +1 button to render –>
    <g:plusone size="tall"></g:plusone>

    <!– Place this render call where appropriate –>
    <script type="text/javascript">
    (function() {
    var po = document.createElement(‘script’); po.type = ‘text/javascript’; po.async = true;
    po.src = ‘https://apis.google.com/js/plusone.js’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(po, s);
    })();
    </script>
    [/php]

    เราแค่เพิ่ม href="<?php the_permalink(); ?>" ลงไปในส่วน g:plusone แบบนี้ครับ

    [php]
    <!– Place this tag where you want the +1 button to render –>
    <g:plusone size="tall" href="<?php the_permalink(); ?>"></g:plusone>

    <!– Place this render call where appropriate –>
    <script type="text/javascript">
    (function() {
    var po = document.createElement(‘script’); po.type = ‘text/javascript’; po.async = true;
    po.src = ‘https://apis.google.com/js/plusone.js’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(po, s);
    })();
    </script>
    [/php]

    เท่านี้ก็เสร็จแล้ว เราสามารถหาข้อมูลของปุ่ม +1 เพิ่มเติมได้ที่ official Google+ button documentation page ครับ ^^