fork download
  1. <?php
  2. /*
  3. Plugin Name: Текст
  4. Description: Текст
  5. Author: Текст
  6. */
  7.  
  8. add_filter( 'the_content', 'wfm_related_posts' );
  9.  
  10.  
  11. function wfm_related_posts($content){
  12.  
  13. if( !is_single() ) return $content;
  14.  
  15. $id = get_the_ID();
  16. $categories = get_the_category( $id );
  17.  
  18. foreach($categories as $category){
  19. $cats_id[] = $category->cat_ID;
  20. }
  21.  
  22. $related_posts = new WP_Query(
  23. 'orderby' => 'title',
  24. 'order' => ASC,
  25. 'posts_per_page' => 4,
  26. 'category__in' => $cats_id,
  27. 'post__not_in' => array($id)
  28. )
  29. );
  30.  
  31. if( $related_posts->have_posts() ){
  32.  
  33. while( $related_posts->have_posts() ){
  34. $related_posts->the_post();
  35. $content .= '<a href="' . get_permalink() . '">' . get_the_title() . '</a><br>';
  36. }
  37.  
  38. $content .= '</div>';
  39. wp_reset_query();
  40. }
  41.  
  42. return $content;
  43. }
Runtime error #stdin #stdout #stderr 0.01s 24400KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Call to undefined function add_filter() in /home/q5mof6/prog.php on line 8