Wordpress template tags: how they show post content & more • wpshout

Yeah, I know sometoàn thân can consider using short emang đến tag a bad practice, I just want to lớn know is there any difference in result of calling these two functions.

Bạn đang xem: Wordpress template tags: how they show post content & more • wpshout


*

The two are not 100% identical, though they are cthảm bại.

the_title() will eđến nội dung by default but the thirdparameter can be used khổng lồ change that mặc định.the_title() prepends the optional $before and appends theoptional $after arguments. If theme or plugin code uses thesearguments the output of the two functions will be different.

If you take a look at the source, the differences are easy to spot:

32 /**33 * Display or retrieve the current post title with optional content.34 *35 *
return string|void String if $echo parameter is false.41 */42 function the_title( $before = "", $after = "", $eđến = true ) 43 $title = get_the_title();44 45 if ( strlen($title) == 0 )46 return;47 48 $title = $before . $title . $after;49 50 if ( $eđến )51 eđến $title;52 else53 return $title;54 You can see that the_title() pulls data using get_the_title() on its first line, so at that point the two are the same. But the_title() then does additional manipulation, potentially.

Xem thêm: Giải Đáp Nhanh: Số Tài Khoản Ngân Hàng Agribank Có Mấy Số, Số Tài Khoản Agribank Có Bao Nhiêu Số

The same is true of some of the other "echo"/"not echo" functions such as the_content() & get_the_content(). While cđại bại, they are not exactly the same.


*

*

the_title()will echo the title for you & can only be used within "the loop" https://codex.wpuonline.com.org/Function_Reference/the_title

get_the_title()without the emang đến or will simply return the title. So you could store it in a variable and manipulate it if you needed to https://codex.wpuonline.com.org/Function_Reference/get_the_title


*

Thanks for contributing an answer lớn wpuonline.com Development Stack Exchange!

Please be sure lớn answer the question. Provide details và nói qua your research!

But avoid

Asking for help, clarification, or responding lớn other answers.Making statements based on opinion; baông xã them up with references or personal experience.

Xem thêm: Cách Sử Dụng Phần Mềm Total Video Converter, Chuyển Đổi Video, Âm Thanh Nhiều Đ

To learn more, see our tips on writing great answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy & cookie policy


Not the answer you're looking for? Browse other questions tagged loop get-the-title or ask your own question.


*

site kiến thiết / hình ảnh sản phẩm © 2021 Stachồng Exchange Inc; user contributions licensed under cc by-sa. rev2021.4.5.38984


wpuonline.com is a trademark of the wpuonline.com Foundation, registered in the US và other countries. This site is not affiliated with the wpuonline.com Foundation in any way.

Your privacy

By clicking “Accept all cookies”, you agree Staông chồng Exchange can store cookies on your device & discthua information in accordance with our Cookie Policy.


Chuyên mục: Theme wordpress