回答編集履歴

2

コードがおかしかった

2017/08/10 11:18

投稿

退会済みユーザー
test CHANGED
@@ -4,7 +4,9 @@
4
4
 
5
5
  function my_custom_single_popular_post( $post_html, $p, $instance ){
6
6
 
7
- $output = '<li><p><a href="' . get_the_permalink($p->id) . '">' . $p->title . '</a></p><p>' . get_the_category_list($p->id) . '</p></li>';}
7
+ $output = '<li><p><a href="' . get_the_permalink($p->id) . '">' . $p->title . '</a></p><p>' . get_the_category_list($p->id) . '</p></li>';
8
+
9
+ }
8
10
 
9
11
  return $output;
10
12
 

1

途中送信した

2017/08/10 11:18

投稿

退会済みユーザー
test CHANGED
@@ -1,16 +1,12 @@
1
+ 変数 $output を1つにして、return で出力できるかも?
2
+
1
3
  ```php
2
4
 
3
5
  function my_custom_single_popular_post( $post_html, $p, $instance ){
4
6
 
5
- $output = '<li>
7
+ $output = '<li><p><a href="' . get_the_permalink($p->id) . '">' . $p->title . '</a></p><p>' . get_the_category_list($p->id) . '</p></li>';}
6
8
 
7
- '<p><a href="'.get_the_permalink($p->id).'">' .$p->title. '</a></p>';
8
-
9
- '<p>'.get_the_category_list($p->id).'</p>';//問題の箇所
10
-
11
- '</li>';
9
+ return $output;
12
-
13
- }
14
10
 
15
11
  add_filter( 'wpp_post', 'my_custom_single_popular_post', 10, 3 );
16
12