WordPress.org

Ready to get started?Download WordPress

Ideas

Exluce certain post data from a WP_Query

  1. philipwalton
    Member

    12345

    get_posts() and WP_Query are great for almost everything, but sometimes I want to query all my posts and only display very basic things about them.

    For example, if I'm making a page that displays a title and link to every single post on my blog, there's no reason for me to query the content of those posts. If I have thousands of posts, and the content for each of those posts is huge, then it would be immensely wasteful for me to store all of that content in a php variable just to get the titles and permalinks to those posts. But that's exactly what these two functions do!

    I would love to be able to do something like this:

    $query = array(
    'numberposts' => -1,
    'exclude_fields' => 'post_content'
    );
    $all_posts = get_posts($query);

    I know I can write a custom query to get some of this information, but when I do that, I lose the ability to use most of the great built-in WordPress function (e.g. the loop functions).

    Posted: 3 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    6 Votes
  • Status

    This idea is under consideration