Archived topic
A way to show unique id in front of the title of every post ?
9 replies · Started by priyankeshu on October 2, 2022
is there a way to show unique ID in the TITLE suffix so it is easy to identify the posts?
let me know!
thanks!
Hello Priyankeshu,
For reference, can you provide a link to a post in your site?
something similar to this
https://generatepress.com/forums/topic/how-to-suffix-or-prefix-the-post-title-in-elements/#post-730638
i don't know if ELEMENTS is the way to show it?
basically i want post titles to go like
UID - Post title - CUSTOMPOSTTAG/category
example-
765 - How to think about dreams - R1 -
I see. Try adding this PHP:
add_filter( 'generate_get_the_title_parameters', function($params){
$params['before'] = '<h1>' . get_the_ID() . '</h1> - ' . $params['before'];
return $params;
},10);
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
hello thanks
i tried and it seems to work, but now the title is going in new line
something like
2856
TITLE GOES HERE
i want something like this
2856 - TITLE GOES HERE - DATE - TAG
also can you suggest how can i customize the code snippet to add TAGs/Categories or CUSTOMCategories in it?
thank you , really appreciate this!
Can you share the link to the site in question? We might need to add some custom CSS to address this.
You may use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information
hi, i had shared it above,
Change the snippet to this:
add_filter( 'generate_get_the_title_parameters', function($params){
$params['before'] = '<h2>' . get_the_ID() . '</h2> - ' . $params['before'];
return $params;
},10);
Then, add this in Appearance > Customize > Additional CSS:
header.entry-header h2 {
display: inline;
}
thanks! man! really appreciate this! i love generatepress support!
last question,
can you suggest me through any tutorial where i can learn more about about this? i mean for example, if i want to learn how to add specific categories tags etc. in similar method.
You're welcome!
Do you mean all categories/tags of a specific post, or just a specific category in general?