0

I've been trying to get into wordpress plugin development but I still haven't figured out how to customize just one part of the template, I've seen the single-{post-type}.php method, but this changes the whole template altogether.

Another method I've seen is short codes, but they become the content as in they are put inside the content container that I'd want to change itself but I want to change the parent.

I guess the most simple way I can exaplain this is that I want to change content.php of a theme for certain post types from a plugin

So let's say that I'm creating a plugin that is going to display a list of items that it's going to get from the database and I need to change only the way it's displayed inside content, what would I do?

0

You can't override template parts. Even if you could, you would have no way of knowing what template part you'd need to replace. A theme is only required to have an index.php file and there are no restrictions or naming convention for template parts.

Your options are to create a full template and leave it up to users to better integrate it with their theme (like Woocommerce does, for example), or add a filter to the_content() to customize the markup just within the output of the_content() function.

EDIT- you can override full templates from a plugin via the template filters.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.