Hi @joost-abrahams
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 attribute description
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 1 year, 1 month 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"
https://www.mantablog.nl/aquarium-science/
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);
Hi @joost-abrahams
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 1 year, 1 month 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);