Support » How-To and Troubleshooting » Posts by current author

Posts by current author

  • I modified the core code in version 1.2,1. Now all my custom code I am putting in a plugin. I am new to writing plugins. The below code must select posts by the current author. I also need categories and comment by current author.

    function pref_posts_by_author()  {
      global $wpdb;
      $user = wp_get_current_user();
      $ID = (int) $user->ID;
      $request = "SELECT * FROM $wpdb->posts
        WHERE post_type = 'post' AND post_author = $ID
        ORDER BY post_date DESC";
      return apply_filters ('posts_request', $request);
    apply_filters ('posts_request', pref_posts_by_author() );

    Thanks for any help

Viewing 2 replies - 1 through 2 (of 2 total)
  • You may want to look into something like:

    I used the documentation mentioned for using add_filter and add_action. However, there is no specific documentation for apply_filters or do_action. I did a search of Codex. That’s why I’m on the forum. The above code sample does not work. I have to use filters because I’m modifying the core edit.php for posting list, show categories and show month (all by current author).

    Thanks again for any help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Posts by current author’ is closed to new replies.