I am using cards to display various blog posts and CPTs around my site. They are fairly standard, title, thumbnail, date, excerpt. My client wants to disable the excerpts from showing, but only on one page. Now I can target the page ID and put display: none on the excerpt for that page, but that feels a bit hacky, and what if the client duplicates that page for instance and the new page has a different page ID. Is there a better way to do this?
I know this is more a CSS issue than WordPress, but there could be a function or plugin for this that I don’t know about. TIA.
[ad_2]
Each page or post has it’s own class that you can find within the body tag. This could be something like “postid-8”
That class will allow you to target that page specifically.
Well, you could create a custom field just with a single checkbox. Then output the value of that field as a body class with a custom function, or, better, add a conditional in your post template. In the template, you would then only output the excerpt if the post doesn’t have that checkbox checked. It is also somewhat hacky, but maybe a little more elegant than targeting post-id. If you do it in the template, you can avoid display: none, which is not elegant in such cases.