HTML in Post Type Description
-
Hello! Just trying to display the post type description on a CPT archive, but it needs some html and I can’t seem to do that. Any filter-y ideas? 🙂
-
Good day.
I guess my first question is exactly how much/what type of markup you were hoping for, beyond say just some paragraphs. If just paragraphs are what you need, then line breaks should preserve. I was able to save this as a description as is:
FILMS! More text testing and then some llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllI was going to say a quick application of say
wpautop()would take care of the rest for you, but I tried out thethe_archive_description()function and it preserved all that as well. Yay! Less work.However, if you’re thinking a bit more complex markup, then we probably want to go a separate route.
Most specifically, if you’re comfortable enough with WordPress actions/filters, then we do have a
cptui_pre_register_post_typefilter available that passes in the array of arguments for the post type in question, matching what you’d have if you were usingregister_post_type()yourself.Something like this could be done in your case:
function my_cptui_amend_post_type_args( $args, $post_type_slug, $post_type_settings ) { // Change "movie" to whatever post type you're wanting this for. if ( 'movie' !== $post_type_slug ) { return $args; } $args['description'] = '<div style="color:red">Your post type description</div>'; return $args; } add_filter( 'cptui_pre_register_post_type', 'my_cptui_amend_post_type_args', 10, 3 );Yeah, it kind of takes things out of the UI, but I’ve tested and it works.
Let me know if neither of these work for your usecase, and I can shake my head until something new rattles.
It’s just really basic heading tags and bold and italics and stuff. Paragraphs seem to be in there already. If that’s easy, then grand! But if not, then I’m trying to decide if it’s worth it to take it out of the UI… it’s just for one page right now that I *could* get away with having a simple page since I just learned this particular post type doesn’t need archives, and the single posts are redirected elsewhere, too. I just need the contents of the posts spit out other places. So I could probably just use a page for this and enter the description as text.
Which is not what you want to hear when you just did all that for me. 🙂 Thank you. haha! BUT, this is good because I may have to do this somewhere else in this project and someone else might want it.
I appreciate you! Thank you for your help.
I do what I can 🙂
Let me know if you need anything else, or could use some rubber ducking.
That totally worked, btw. Thank you! It’s pretty straightforward, especially if it’s just for a couple and not a whole ton.
YAY. Thank you!
The topic ‘HTML in Post Type Description’ is closed to new replies.