Support » Plugin: Extended Post Status » Show post status description in theme
Show post status description in theme
-
Hi how to show the status description in the theme, you got a example or now of a theme that does it?
-
unfortunately there is no defined standard here. But since statuses are only stored as standard terms in WordPress you can get the status with the function
get_term_by()
and then access the attributedescription
there.I have created this as a small debugging page template. So you can test it.
<?php /* Template Name: Example Template */ echo '<pre>'; $statusDescription = get_term_by('slug', get_post_status(), 'status'); var_dump($statusDescription->description); echo '</pre>'; exit;
In a child theme, for example, you could work with it to access the description of the status.
I hope this helps you.
Greetings Felix
Hi @joost-abrahams
i have not heard from you again, so i am closing this thread and hope you have moved on with my reply.
Greetings Felix
-
This reply was modified 3 weeks, 3 days ago by
Felix W..
Thanks for the code @welly2103
add_action('generate_before_page_title', function(){ echo '<pre>'; $statusDescription = get_term_by('slug', get_post_status(), 'status'); var_dump($statusDescription->description); echo '</pre>'; },5);
i did put this in my functions.php without
exit;
but it echo more then then status description:
Like:
string(21) "Needs to be proofread"
oww sorry fixed it with:
add_action('generate_before_page_title', function(){ echo '<pre>'; $statusDescription = get_term_by('slug', get_post_status(), 'status'); echo($statusDescription->description); echo '</pre>'; },5);
nice to hear from you.
The <pre> tag is only for testing purposes, you don’t necessarily need that. You can also just output the description with the hook used.
With that this code would be enough:
add_action('generate_before_page_title', function(){ $statusDescription = get_term_by('slug', get_post_status(), 'status'); echo($statusDescription->description); },5);
Greetings Felix
-
This reply was modified 2 weeks ago by
Felix W..
Hi @welly2103
I did pimp it up a bit, looks very nice now. i am a noob at php, css i understand better. The code used:
add_action('generate_before_page_title', function(){ echo '<figure class="wp-block-pullquote has-contrast-3-background-color has-background has-large-font-size">'; $statusDescription = get_term_by('slug', get_post_status(), 'status'); echo($statusDescription->description); echo '</p></blockquote></figure>'; },5);
it look great now: https://www.mantablog.nl/aquarium-science/home-page/7-filter-media/
thanks @welly2103
-
This reply was modified 3 weeks, 3 days ago by
- You must be logged in to reply to this topic.