Replies: 0
Earlier on in a course I’m doing we were told any function in WP beginning with ‘get’ returns only the value to the calling statement, whilst the counter WP functions beginning with ‘the’ will handle echoing to the screen/page.
<p><?php echo wp_trim_words(get_the_content(), 18) ?> <a href="<?php the_permalink(); ?>" class="nu gray">Read more</a></p>
I thought I’d understood this but it seems I haven’t and to be honest this doesn’t make much sense to me looking at the above code segment which works fine. To me I’ve taken echoing to the screen to mean the end users screen who is viewing the web page not the IDE screen. So firstly is this the correct interpretation?
wp_trim_words(get_the_content(), 18)
As I understand it this returns a value i.e. the post content to the function WP_TRIM_WORDS. If I use THE_CONTENT instead it won’t output what I want due to the embedded echo. So what’s going on here? Does this mean the content will end up being echoed to the end user before WP_TRIM_WORDS has a chance to work on it?
<a href="<?php the_permalink(); ?>
We want this to end up looking like this…
<a href=”http://test.local/2019/01/03/miniature-uav/”
I want to embed the URL string into the statement not echo the URL string to the screen output. So why can’t I use GET_THE_PERMALINK()? Why do I have to use THE_PERMALINK() and doesn’t this, like THE_CONTENT() function above do, echo to the end user as a string?
Could someone please, please clarify before I go bonkers.