-
ID:OuQIDV さんの質問

wordpressで機能が追加できない箇所が3箇所あります。
ここ数日ネットで調べてみているのですが。
この3箇所が設置できず、困っております。
お知恵を借りれればと思います。 ちなみにワードプレス、PHPに関しては初心者です。

①アドセンスの設置

②ハッシュタグでtwitter検索した結果を表示して自動更新する機能の設置

下記のサイトでjavascriptを取得し設置しようとしたのですが、
wordpressはjavascriptをそのまま設置しても機能できないようでした。
いろいろjavascriptをwordpressでも利用できる方法を調べたのですが、
うまく行きませんでした。
javascriptを使えるようにするか
下記のサイトのコードでなくてもよいので、同様のワードプレスのプラグイン等があれば教えていただければと思います。
d.hatena.ne.jp/stealthinu/20100531/p2

③buddypressでのブログ機能の追加。
下記のサイトを参考にで実行しようとしたのですが、
「3. WordPress3.0でマルチサイトの設定」でつまずき、うまくいきません。

www.webcreatorbox.com/tech/wordpress-plugin-buddypress/

よろしくお願いします。

みんなの回答 4 件

ID:HzYkwt さんの回答

1、2はテーマファイル(index.phpとかsingle.phpとか)に発行されたコードをそのまま貼り付ければいいですよ。動かないのはWordPressの原因じゃないです。

ID:bazCt9 さんの回答

3の”つまづき、うまくいきません”だとこちらもわかりません。
手順については参考サイトをそのままだと思いますが、何がうまくいかないのか、エラーがでていればソノエラーなど提示していただかないと回答者も答えようがないと思います。

ID:VEr9UU さんの回答

ありがとうございます^^
試してみます!

ID:WrCYEe さんの回答

質問者です。

アドセンスの設置はうまく行きました。
しかしながら、ツイッターのjavascriptの箇所がうまく表示されません。
index.phpにこのような形でコードを追加してみたのですが、
結果下記のような表示が出てしまいうまくいきません。

※指定されたページ(URL)へのアクセスは禁止されています。

fc2ブログではhtmlに書き込んでうまく動作しました。
どこが問題なのでしょうか。

<?php get_header(); ?> 
 
 
 
 
 <div id="content"> 
 
 
<!--twitterタイムライン--> 
 
<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script> 
<script type="text/javascript"> 
function updateLoop(search_word, count) { 
  var update_time = 2*60; // sec 
  var callback_func = "twitterSearchCallback"; 
  var api_url = "http://search.twitter.com/search.json?q=" 
 +encodeURIComponent(search_word)+"&rpp="+count+"&callback="+callback_func; 
  callJSONP(api_url); 
  timerID = setInterval(function(){callJSONP(api_url)},update_time*1000); 

 
function twitterSearchCallback(searchs) { 
  var s = convertSearchedTweets(searchs); 
  document.getElementById("twitter_update_list").innerHTML = "<ul>"+s+"</ul>"; 

 
function convertSearchedTweets(searchs) { 
  var s=""; 
  for(var i in searchs["results"]){ 
    var username = searchs["results"][i].from_user; 
    var id = searchs["results"][i].id; 
    var profile_image_url = searchs["results"][i].profile_image_url; 
    var reltime = relative_time(searchs["results"][i].created_at); 
    var status = searchs["results"][i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) { 
      return '<a href="'+url+'">'+url+'</a>'; 
    }).replace(/\B@([_a-z0-9]+)/ig, function(reply) { 
      return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>'; 
    }); 
    s+='<li><img src="'+profile_image_url+'" width=48 height=48> <a href="http://twitter.com/'+username+'">'+username+'</a>: <span>'+status+'</span> <a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+id+'">'+reltime+'</a></li>'; 
  } 
  return s; 

 
function callJSONP(url) {   
  var target = document.createElement('script');   
  target.charset = 'utf-8';   
  target.src = url;   
  document.body.appendChild(target);   

 
updateLoop("#ipadjp", 30); 
</script> 
 
 
<!--twitterタイムライン--> 
 
  <div class="padder"> 
 
  <?php do_action( 'bp_before_blog_home' ); ?> 
 
  <?php do_action( 'template_notices' ); ?> 
 
  <div class="page" id="blog-latest" role="main"> 
 
   <?php if ( have_posts() ) : ?> 
 
    <?php bp_dtheme_content_nav( 'nav-above' ); ?> 
 
    <?php while (have_posts()) : the_post(); ?> 
 
     <?php do_action( 'bp_before_blog_post' ); ?> 
 
     <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
 
      <div class="author-box"> 
       <?php echo get_avatar( get_the_author_meta( 'user_email' ), '50' ); ?> 
       <p><?php printf( _x( 'by %s', 'Post written by...', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ); ?></p> 
 
       <?php if ( is_sticky() ) : ?> 
        <span class="activity sticky-post"><?php _ex( 'Featured', 'Sticky post', 'buddypress' ); ?></span> 
       <?php endif; ?> 
      </div> 
 
 
      <div class="post-content"> 
    <h2 class="posttitle"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ); ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> 
 
       <p class="date"><?php printf( __( '%1$s <span>in %2$s</span>', 'buddypress' ), get_the_date(), get_the_category_list( ', ' ) ); ?></p> 
 
       <div class="entry"> 
        <?php the_content( __( 'Read the rest of this entry &rarr;', 'buddypress' ) ); ?> 
        <?php wp_link_pages( array( 'before' => '<div class="page-link"><p>' . __( 'Pages: ', 'buddypress' ), 'after' => '</p></div>', 'next_or_number' => 'number' ) ); ?> 
       </div> 
 
       <p class="postmetadata"><?php the_tags( '<span class="tags">' . __( 'Tags: ', 'buddypress' ), ', ', '</span>' ); ?> <span class="comments"><?php comments_popup_link( __( 'No Comments &#187;', 'buddypress' ), __( '1 Comment &#187;', 'buddypress' ), __( '% Comments &#187;', 'buddypress' ) ); ?></span></p> 
      </div> 
 
     </div> 
 
     <?php do_action( 'bp_after_blog_post' ); ?> 
 
    <?php endwhile; ?> 
 
    <?php bp_dtheme_content_nav( 'nav-below' ); ?> 
 
   <?php else : ?> 
 
    <h2 class="center"><?php _e( 'Not Found', 'buddypress' ); ?></h2> 
    <p class="center"><?php _e( 'Sorry, but you are looking for something that isn\'t here.', 'buddypress' ); ?></p> 
 
    <?php get_search_form(); ?> 
 
   <?php endif; ?> 
  </div> 
 
  <?php do_action( 'bp_after_blog_home' ); ?> 
 
  </div><!-- .padder --> 
 </div><!-- #content --> 
 
 <?php get_sidebar(); ?> 
 
<?php get_footer(); ?> 
ID:vCcDeq

2についてはコード古い気がします。index.phpに貼りつけたTwitter用コードの部分は削除して下さい。で、2の記事でも追記されていますが、今はTwitter自体がウィジェットを出しているので、それをWordPressのサイドバーなり記入したい部分に貼り付ければ良いと思います。以下の記事が参考になるかと思います。

WordPressのサイドバーにTwitterウィジェットを表示する方法 | prime factor
ttp://succi.jp/blog/?p=157

ID:vCcDeq

作業時に問題の切り分けをする意味で、Twitterのコード貼り付けの際にはBuddyPressについてはプラグインの管理画面で無効化しておいて下さい。

推測ですが「※指定されたページ(URL)へのアクセスは禁止されています。」はBuddyPressの設定が問題なのではと思います。

ID:WrCYEe

ありがとうございます。
試してみます。

ID:WrCYEe

「WordPressのサイドバーにTwitterウィジェットを表示する方法」なのですが、
自分のサイトのツイートを表示させるのではなく、下記のようなサイトのように
ツイッター上の指定した情報を集めて、表示させたいと考えています。

kunitter.com/
jobhun.jp/

kunitterでは、国立市関連のツイートを集めて一覧で表示させています。
jobhunでは、就職活動関連のツイートを集めて一覧で表示させています。

よろしくお願いします。

最終更新日:2013-01-20 (3,356 views)

関連するトピックス

ページ上部に戻る