Joy
(@joyously)
For clarity, permalink is just a developer’s term for the permanent address of some content.
I can’t tell if you are asking about the presentation of the page being linked to, or the page that contains the link.
Are you writing a theme? Or are you writing content on your site?
The theme usually handles how each page is presented, and the content author handles what the content looks like.
If you want to change how the pages are shown, you should change your theme, or make a child theme to add some CSS or functions to present things differently, or just add CSS in Customizer > Additional CSS.
I’m developing a new theme. I already was thinking it wasn’t really clear after in entered it.
I want to style te page that is opened when clicking a permalink. In my case this is a post. I already got some pages/templates as a page.teplate-info.php (for example). Would it also be possible to style a certain category for posts?
Like I choose it belongs to the category ‘portfolio’, and than style the post/page that’s behind this category?
There is not a post template hierarchy for assigned taxonomy terms, so you cannot do so with a certain template name with the default hierarchy. What you could do is output the category term slug in the single post’s body tag class. Then for certain predefined category terms specify certain CSS be applied which includes the body class in every applicable CSS selector.
For example, lets say you want to have an aqua background color for posts in the category “foobar”. Your header.php template which outputs the body tag might in this specific case include the body tag attribute class="post-template-default single single-post postid-2 foobar"
Your CSS then could include the rule
body.single-post.foobar {
background-color: aqua;
}
If you really need a specific template file be used for “foobar” category posts because the layout goes beyond CSS adjustments, you can use the “template_include” filter to override the usual template hierarchy that WP uses.
Joy
(@joyously)
You should read about the Template Hierarchy so you know how the name of the template affects which one is selected for use.
Page templates that you want the user to select for individual pages should not be named starting with page- because this is for pages with particular slugs.
You can make a template file for individual taxonomies (even to the term for custom taxonomies).
If you are writing a theme for distribution, you should not have any template files with individual slugs, because of translation.
Also, themes should not be handling custom post types or custom taxonomies, as they have to handle all content to display and don’t know the details of the custom post type or taxonomy. (Themes just display stuff, not create or define it.)
If you are writing a theme just for your own site, start with an existing theme and modify it. Don’t put custom types or taxonomies in it, because you need to be able to change themes later (especially if your site is hacked — the theme is often targeted since it is used on every page load).
One way a theme can treat different types of content uniquely is by using post formats. So if all of your portfolio category posts were marked as gallery post format, the theme can display them a certain way. Same for audio and video, etc.
You might want to read up on writing themes, in the Theme Handbook.
I solved it another way: by adding the wordpress-classes to the body tag. And then giving style to the class-items.
Thanks for your response for now!