wpプラグインulikeは記事に対して言い値ボタンを設置できるものですが、記事一覧に設置するための設定はありません、そこで、
wpプラグインulikeボタンを記事一覧でも表示させる方法です。
// Ulike button output; if( !function_exists('get_the_ulike_btn') ){ function get_the_ulike_btn( $post_id ){ global $wp_ulike_class,$wp_user_IP; $get_post_meta = get_post_meta($post_id, '_liked', true); $get_like = $get_post_meta != '' ? $get_post_meta : 0; $return_userID = $wp_ulike_class->get_reutrn_id(); $theme_class = wp_ulike_get_setting( 'wp_ulike_posts', 'theme'); $data = array( "id" => $post_id , //Post ID "user_id" => $return_userID, //User ID (if the user is guest, we save ip as user_id with "ip2long" function) "user_ip" => $wp_user_IP, //User IP "get_like" => $get_like, //Number Of Likes "method" => 'likeThis', //JavaScript method "setting" => 'wp_ulike_posts', //Setting Key "type" => 'post', //Function type (post/process) "table" => 'ulike', //posts table "column" => 'post_id', //ulike table column name "key" => '_liked', //meta key "cookie" => 'liked-' //Cookie Name ); //call wp_get_ulike function from class-ulike calss $counter = $wp_ulike_class->wp_get_ulike($data); $wp_ulike = ''; $wp_ulike .= ''; $wp_ulike .= $wp_ulike_class->get_liked_users($post_ID,'ulike','post_id','wp_ulike_posts'); echo $wp_ulike; } }'.$counter.''; $wp_ulike .= '
上記をfunction.phpに記述したら,
ループ分の中で下記を記述するとUlikeボタンを表示させることが可能です。
ID' ); ?>