Make WordPress Core

Opened 2 years ago

#42958 new defect (bug)

create callers for loop functions to accept post id

Reported by: tazotodua Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:


I've always been surprised, why the loop functions (like the_title, the_content, the_post_thumbnail and etc) doesnt have ability to accept post-id as argument.
I think that the get_..... functions is not replacement in MANY MANY cases, whereas the_... functions automatically generate all the needed attributes and tags. using the get_ function, it is hard to hardcode all those things manually.
I suggest to revise once again and why wont WP create callers, like i.e.

_the_content($post_id, [other parameters as of now...])
_the_title($post_id, [other parameters as of now...])

this will make the things much easier for developers. If you dont believe, see how hard it is to get the same result as the_content for specific post id (while outside of loop):

//save global variable
$target_post_id = 14;

//change global variable temporarily, to deceive WP
//ONLY NOW call get_the_content
$content = get_the_content( $more_link_text='Read more', $strip_teaser=false );
$content = apply_filters( 'the_content', $content );
$content = str_replace( ']]>', ']]>', $content );

//restore the global variable

echo $content;

this is real equivalent of the_content when you need to call outside of loop. Is it still arguable??

Change History (0)

Note: See TracTickets for help on using tickets.