2011-07-19 4 views
0

"fb_comment_count"と "my_post_gallery"の2つの関数:Pastebinがあります。関数は、目的のスパンタグの外にhtmlを配置します

123行目では、「fb_comment_count」を使用していることがわかります。問題は、生成されたマークアップが、それらのspanタグの中にコメントカウント番号を置くのではなく、他の場所に配置することです。

以下は、私が意味するものを示すために生成されたマークアップです。すべてのコメント数(aタグ)は先頭にプッシュされ、spanタグ(<span class="comment-number"></span>)は空です。なぜこのようなことが起こるのか理解できる人はいますか? PHPの関数を使用returnの代わりecho

<section class="tab_content" id="tab1" style="display: block;"> 
    <a title="Comments for Photos" href="http://mysite.com/test/photos/#comments">0</a> 
    <a title="Comments for Photos" href="http://mysite.com/test/photos/#comments">0</a> 
    <a title="Comments for Photos" href="http://mysite.com/test/photos/#comments">0</a> 
    <a title="Comments for Photos" href="http://mysite.com/test/photos/#comments">0</a> 
    <a title="Comments for Photos" href="http://mysite.com/test/photos/#comments">0</a> 
    <a title="Comments for Photos" href="http://mysite.com/test/photos/#comments">0</a> 
    <a title="Comments for Photos" href="http://mysite.com/test/photos/#comments">0</a> 
    <a title="Comments for Photos" href="http://mysite.com/test/photos/#comments">0</a> 
    <style type="text/css"> 
     #gallery-1 { 
      margin: auto; 
     } 
     #gallery-1 .gallery-item { 
      float: left; 
      margin-top: 10px; 
      text-align: center; 
      width: 33%;   } 
     #gallery-1 img { 
      border: 2px solid #cfcfcf; 
     } 
     #gallery-1 .gallery-caption { 
      margin-left: 0; 
     } 
    </style> 
     <!-- see gallery_shortcode() in wp-includes/media.php --> 
     <div class="gallery galleryid-818" id="gallery-1"><div class="gallery-item"><span class="photos-comment-number-wrap"><span class="comment-number"></span></span> 
      <span class="gallery-icon"> 
       <a title="fff" href="http://mysite.com/test/photos/attachment/fff/"><img width="150" height="150" title="fff" alt="fff" class="attachment-thumbnail" src="http://mysite.com/test/wp-content/uploads/2011/06/fff-150x150.gif"></a> 
      </span></div><div class="gallery-item"><span class="photos-comment-number-wrap"><span class="comment-number"></span></span> 
      <span class="gallery-icon"> 
       <a title="plate with 5" href="http://mysite.com/test/photos/attachment/plate-with-5/"><img width="150" height="150" title="plate with 5" alt="plate with 5" class="attachment-thumbnail" src="http://mysite.com/test/wp-content/uploads/2011/06/plate-with-5-150x150.jpg"></a> 
      </span></div><div class="gallery-item"><span class="photos-comment-number-wrap"><span class="comment-number"></span></span> 
      <span class="gallery-icon"> 
       <a title="reference" href="http://mysite.com/test/photos/attachment/reference/"><img width="150" height="150" title="reference" alt="reference" class="attachment-thumbnail" src="http://mysite.com/test/wp-content/uploads/2011/06/reference-150x150.png"></a> 
      </span></div><br style="clear: both"><div class="gallery-item"><span class="photos-comment-number-wrap"><span class="comment-number"></span></span> 
      <span class="gallery-icon"> 
       <a title="test" href="http://mysite.com/test/photos/attachment/test/"><img width="150" height="150" title="test" alt="test" class="attachment-thumbnail" src="http://mysite.com/test/wp-content/uploads/2011/06/test-150x150.jpg"></a> 
      </span></div><div class="gallery-item"><span class="photos-comment-number-wrap"><span class="comment-number"></span></span> 
      <span class="gallery-icon"> 
       <a title="test-24" href="http://mysite.com/test/photos/attachment/test-24/"><img width="150" height="150" title="test-24" alt="test-24" class="attachment-thumbnail" src="http://mysite.com/test/wp-content/uploads/2011/06/test-24-150x150.gif"></a> 
      </span></div><div class="gallery-item"><span class="photos-comment-number-wrap"><span class="comment-number"></span></span> 
      <span class="gallery-icon"> 
       <a title="test-pilot" href="http://mysite.com/test/photos/attachment/test-pilot/"><img width="150" height="150" title="test-pilot" alt="test-pilot" class="attachment-thumbnail" src="http://mysite.com/test/wp-content/uploads/2011/06/test-pilot-150x150.png"></a> 
      </span></div><br style="clear: both"><div class="gallery-item"><span class="photos-comment-number-wrap"><span class="comment-number"></span></span> 
      <span class="gallery-icon"> 
       <a title="its-hackin-christmas" href="http://mysite.com/test/photos/attachment/blah"><img width="133" height="133" title="its-hackin-christmas" alt="its-hackin-christmas" class="attachment-thumbnail" src="http://mysite.com/test/wp-content/uploads/2011/06/blah.jpg"></a> 
      </span></div><div class="gallery-item"><span class="photos-comment-number-wrap"><span class="comment-number"></span></span> 
      <span class="gallery-icon"> 
       <a title="who-wants-to-party" href="http://mysite.com/test/photos/attachment/who-wants-to-party/"><img width="133" height="133" title="who-wants-to-party" alt="who-wants-to-party" class="attachment-thumbnail" src="http://mysite.com/test/wp-content/uploads/2011/06/who-wants-to-party.jpg"></a> 
      </span></div> 
      <br style="clear: both;"> 
     </div> 
</section> 

答えて

1

。そう、たとえばのため、代わりにライン26でこれを持つの:

echo $comments; 

変更それに:

return $comments; 

同じことがechoと、他のラインのために行きます。私が欲しかったけど、それは私が< `直接この\t \t \t \t \t \tのような機能を呼んでいるサイトの別の部分に完全に数字を処分したように、` span`タグ内の番号を取得することにより、働い

+0

span class = "コメント番号"><?php fb_comment_count(); ?> '別の方法がありますか? – J82

+0

他の場所では、結果をエコーすることができます: '<?php echo fb_comment_count(); ?> '(その行に' echo 'が追加されています) –

+0

ああ、完璧です。ありがとうございました。 :) – J82

関連する問題