How to Check whether the_excerpt() function is called in a particular page example in a archive page.
The thing is i want to know whether the_excerpt() function is used to display the content or whether the_content() is used to display the content in archive/category pages.
How to check this. Is there any conditional tag
There is no conditional tag, but there is a filter. If you hook into the
'get_the_excerpt'
filter, your function will run. So, as an example:Then, to check whether an excerpt was used, any time after the first iteration of the loop, use this:
This isn’t a very elegant or useful way of doing it, but this is how you would do it. If you need to know whether a template will use the excerpt before it loads the template, you’d have to hook this earlier, use
fopen()
to read through the template file and search forthe_excerpt()
.