Support » Requests and Feedback » Ideas for WP_Post and template tag improvements

  • This idea is a simple one: encapsulating the post-based template tags (the_ID, the_title, the_content, etc) and make them methods of the WP_Post object.

    Basically what this does is allow developers and theme makers to take advantage of the template tags in custom loops without actually messing around with the main loop or the global $post and removing the need to reset post data. Since the template tags use post data to begin, it makes sense for the core logic to be in the WP_Post class. The global template tags can just call the methods of the global $post object in a main loop.

    For example if you have a custom query:

    $query = new WP_Query();

    Instead of calling the_post to load the global variables, you could do:

    while( $query->have_posts ) : $query->next_post();

    Basically, you call the template tags directly from the post instead of messing with the main loop variables.

  • The topic ‘Ideas for WP_Post and template tag improvements’ is closed to new replies.