php - Custom function Wordpress not stopping after return -
good day!
as title says custom function not stopping after return. have created child theme , create function inside functions.php file.
what try achieve show category title otherwise string home title.
what end getting both category title , string of home if click on category.
html:
<h3><?php echo header_title() ?> </h3>
php:
function header_title() { if(single_cat_title() != null) { return single_cat_title(); } else { return 'home'; } }
anyone knows went wrong here?
any appreciated here :)
single_cat_title
return value if set second ($display
) argument false
. since you're not specifying it, it's echo
ing value, returning nothing, , you're dropping through else
condition.
try providing parameter (eg if(single_cat_title('', false) != null) {
) in both calls. or store result.
Comments
Post a Comment