ワードプレスのコメント欄に各種ソーシャルメディアボタンを設置したいのですが、うまくいきません。
どういったコードを埋め込み、どの箇所にいれればよいでしょうか。
具体的にいいますと。記事に対しての各コメントごとにいいね等が設置できるようにしたいです。
忍者おまとめボタンというツールでワードプレス用のコードを取得しcomments.phpに埋め込みました。
しかしながら、403というエラーで以下のような文言のエラーが表示されます。※指定されたページ(URL)へのアクセスは禁止されています。
上記がcommnts.phpのコードです。ソーシャルメディアボタンとはfacebook、twitter,google+,line,mixi,はてなブックーマークのボタンを指します。よろしくお願いします。
<?php if ( post_password_required() ) { echo '<h3 class="comments-header">' . __( 'Password Protected', 'buddypress' ) . '</h3>'; echo '<p class="alert password-protected">' . __( 'Enter the password to view comments.', 'buddypress' ) . '</p>'; return; } if ( is_page() && !have_comments() && !comments_open() && !pings_open() ) return; if ( have_comments() ) : $num_comments = 0; $num_trackbacks = 0; foreach ( (array) $comments as $comment ) { if ( 'comment' != get_comment_type() ) $num_trackbacks++; else $num_comments++; } ?> <div id="comments"> <h3> <?php printf( _n( '1 response to %2$s', '%1$s responses to %2$s', $num_comments, 'buddypress' ), number_format_i18n( $num_comments ), '<em>' . get_the_title() . '</em>' ); ?> </h3> <?php do_action( 'bp_before_blog_comment_list' ); ?> <ol class="commentlist"> <?php wp_list_comments( array( 'callback' => 'bp_dtheme_blog_comments', 'type' => 'comment' ) ); ?> </ol><!-- .comment-list --> <?php do_action( 'bp_after_blog_comment_list' ); ?> <?php if ( get_option( 'page_comments' ) ) : ?> <div class="comment-navigation paged-navigation"> <?php paginate_comments_links(); ?> </div> <?php endif; ?> </div><!-- #comments --> <?php else : ?> <?php if ( pings_open() && !comments_open() && ( is_single() || is_page() ) ) : ?> <p class="comments-closed pings-open"> <?php printf( __( 'Comments are closed, but <a href="%1$s" title="Trackback URL for this post">trackbacks</a> and pingbacks are open.', 'buddypress' ), trackback_url( '0' ) ); ?> </p> <?php elseif ( !comments_open() && ( is_single() || is_page() ) ) : ?> <p class="comments-closed"> <?php _e( 'Comments are closed.', 'buddypress' ); ?> </p> <?php endif; ?> <?php endif; ?> <?php if ( comments_open() ) : ?> <?php comment_form(); ?> <?php endif; ?> <?php if ( !empty( $num_trackbacks ) ) : ?> <div id="trackbacks"> <h3><?php printf( _n( '1 trackback', '%d trackbacks', $num_trackbacks, 'buddypress' ), number_format_i18n( $num_trackbacks ) ); ?></h3> <ul id="trackbacklist"> <?php foreach ( (array) $comments as $comment ) : ?> <?php if ( 'comment' != get_comment_type() ) : ?> <li> <h5><?php comment_author_link(); ?></h5> <em>on <?php comment_date(); ?></em> </li> <?php endif; ?> <?php endforeach; ?> </ul> </div> <?php endif; ?> <!-- #このソーシャルメディアボタンを入れようとしました。 --> <div class="ninja_onebutton"> <script type="text/javascript"> //<![CDATA[ (function(d){ if(typeof(window.NINJA_CO_JP_ONETAG_BUTTON_3b18b0447eecc9b82802e5a412001737)=='undefined'){ document.write("<sc"+"ript type='text\/javascript' src='http:\/\/omt.shinobi.jp\/b\/3b18b0447eecc9b82802e5a412001737'><\/sc"+"ript>"); }else{ window.NINJA_CO_JP_ONETAG_BUTTON_3b18b0447eecc9b82802e5a412001737.ONETAGButton_Load();} })(document); //]]> </script><span class="ninja_onebutton_hidden" style="display:none;"><?php the_permalink(); ?></span><span style="display:none;" class="ninja_onebutton_hidden"><?php the_title(); ?></span> </div> <!-- #このソーシャルメディアボタンを入れようとしました。 -->
ほーむぺーじのつくりかたみたいなほんをよんではどうでしょうか
質問文の書き方からみて完全な解答を書かないと理解してくれそうにない気がする。リンク先は忍者おまとめボタンをプラグインを使って配置する方法で、これでも無理なら(ソースの編集しなきゃいけないので)諦めた方がいいかも。
コードが分からない → プラグインを使う → プラグインの使い方が分からない → 誰も教えてくれない(聞いてもわからない) → お手上げ
目的を達成できない理由がどこにあるのか考えてみよう。
自社のプログラマーに聞けよ!
ぷぷぷぷ、プラグインってのがあるんだな(ToT)
みんなの回答 5 件
上記がcommnts.phpのコードです。
ソーシャルメディアボタンとはfacebook、twitter,google+,line,mixi,はてなブックーマークのボタンを指します。
よろしくお願いします。
<?php
if ( post_password_required() ) {
echo '<h3 class="comments-header">' . __( 'Password Protected', 'buddypress' ) . '</h3>';
echo '<p class="alert password-protected">' . __( 'Enter the password to view comments.', 'buddypress' ) . '</p>';
return;
}
if ( is_page() && !have_comments() && !comments_open() && !pings_open() )
return;
if ( have_comments() ) :
$num_comments = 0;
$num_trackbacks = 0;
foreach ( (array) $comments as $comment ) {
if ( 'comment' != get_comment_type() )
$num_trackbacks++;
else
$num_comments++;
}
?>
<div id="comments">
<h3>
<?php printf( _n( '1 response to %2$s', '%1$s responses to %2$s', $num_comments, 'buddypress' ), number_format_i18n( $num_comments ), '<em>' . get_the_title() . '</em>' ); ?>
</h3>
<?php do_action( 'bp_before_blog_comment_list' ); ?>
<ol class="commentlist">
<?php wp_list_comments( array( 'callback' => 'bp_dtheme_blog_comments', 'type' => 'comment' ) ); ?>
</ol><!-- .comment-list -->
<?php do_action( 'bp_after_blog_comment_list' ); ?>
<?php if ( get_option( 'page_comments' ) ) : ?>
<div class="comment-navigation paged-navigation">
<?php paginate_comments_links(); ?>
</div>
<?php endif; ?>
</div><!-- #comments -->
<?php else : ?>
<?php if ( pings_open() && !comments_open() && ( is_single() || is_page() ) ) : ?>
<p class="comments-closed pings-open">
<?php printf( __( 'Comments are closed, but <a href="%1$s" title="Trackback URL for this post">trackbacks</a> and pingbacks are open.', 'buddypress' ), trackback_url( '0' ) ); ?>
</p>
<?php elseif ( !comments_open() && ( is_single() || is_page() ) ) : ?>
<p class="comments-closed">
<?php _e( 'Comments are closed.', 'buddypress' ); ?>
</p>
<?php endif; ?>
<?php endif; ?>
<?php if ( comments_open() ) : ?>
<?php comment_form(); ?>
<?php endif; ?>
<?php if ( !empty( $num_trackbacks ) ) : ?>
<div id="trackbacks">
<h3><?php printf( _n( '1 trackback', '%d trackbacks', $num_trackbacks, 'buddypress' ), number_format_i18n( $num_trackbacks ) ); ?></h3>
<ul id="trackbacklist">
<?php foreach ( (array) $comments as $comment ) : ?>
<?php if ( 'comment' != get_comment_type() ) : ?>
<li>
<h5><?php comment_author_link(); ?></h5>
<em>on <?php comment_date(); ?></em>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<!-- #このソーシャルメディアボタンを入れようとしました。 -->
<div class="ninja_onebutton">
<script type="text/javascript">
//<![CDATA[
(function(d){
if(typeof(window.NINJA_CO_JP_ONETAG_BUTTON_3b18b0447eecc9b82802e5a412001737)=='undefined'){
document.write("<sc"+"ript type='text\/javascript' src='http:\/\/omt.shinobi.jp\/b\/3b18b0447eecc9b82802e5a412001737'><\/sc"+"ript>");
}else{
window.NINJA_CO_JP_ONETAG_BUTTON_3b18b0447eecc9b82802e5a412001737.ONETAGButton_Load();}
})(document);
//]]>
</script><span class="ninja_onebutton_hidden" style="display:none;"><?php the_permalink(); ?></span><span style="display:none;" class="ninja_onebutton_hidden"><?php the_title(); ?></span>
</div>
<!-- #このソーシャルメディアボタンを入れようとしました。 -->
質問文の書き方からみて完全な解答を書かないと理解してくれそうにない気がする。リンク先は忍者おまとめボタンをプラグインを使って配置する方法で、これでも無理なら(ソースの編集しなきゃいけないので)諦めた方がいいかも。
ソーシャルボタンをプラグインを使って簡単に設置する方法 | Punksteady
http://punksteady.com/2012/03/18/sns/コードが分からない → プラグインを使う → プラグインの使い方が分からない → 誰も教えてくれない(聞いてもわからない) → お手上げ
目的を達成できない理由がどこにあるのか考えてみよう。
自社のプログラマーに聞けよ!
ぷぷぷぷ、プラグインってのがあるんだな(ToT)
関連するトピックス