erick_paper
Member
Posted 4 years ago #
The templating engine of WP seems to be mighty inconsistent.
- the_title() has a parameter that allows me to use it as a variable in my PHP:
the_title('', '', FALSE).
- the_ID() is equally useful if not more (for doing some custom SQL in the page) but doesn't have this feature to send parameters and get the ID as a value instead of displaying it.
- the_content() also doesn't have any parameter for returning the html-stripped (text only) to use in PHP instead of simply displaying it.
Any ideas on how I can get the value of the current post's ID and content? I want to use this in my Single Post template to run a query (to show related posts).
Thanks!
2. get_the_ID()
3. get_the_content()
Not an oft mentioned feature and its more a recent development, but most (though not all) template tags have a corresponding get_the_* function that returns its value. There is even a - surprise! - get_the_title().
In fact, many of the the_* functions are mere (echo) wrappers for get_the_* functions.
erick_paper
Member
Posted 4 years ago #
Wow, this is splendid, thank you!!!
Thanks, this was exactly what I've been looking for.
I wonder why such an important function is so unknown. I need get_the_ID() more often then I need the_ID()!!!!
It should be at least mentioned on codex!!!! It's practically impossible to find it!!