WordPress.org

Ready to get started?Download WordPress

Forums

Posts by current author (3 posts)

  1. tsbalaban
    Member
    Posted 7 years ago #

    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

  2. moshu
    Member
    Posted 7 years ago #

    You may want to look into something like:
    http://codex.wordpress.org/Developer_Documentation

  3. tsbalaban
    Member
    Posted 7 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic