I'm an ambitious wordpress beginner and learner - this is my first question at Stackexchange - in case I'm wrong here, I'm grateful for anyone pointing in a better direction.

On my page http://www.project22.org

  • I started off with a childtheme of Twenty Twelve, because I thought this theme is particularly well prepared for anything that might come.
  • Next I created my own 'base-functionality-plugin', to do the programming that I (didn't find in other plugins) and that I wanted to do myself.

Now, I have basically created the functionalities I wanted in my plugin, but to display my results I needed to some adjustments in the (child) theme files, e.g. the content.php to change the display of the "entry_meta" of posts.

This doesn't feel right, wouldn't it be best if my plugin remains independent of the theme itself?

So my beginner questions are these:

  • How to avoid this?
  • What is the best practice regarding this?
  • What to do if your starting theme has no hooks or filters in the places you need?

Edit: My use case - in the entry_meta of each post I want to display some data from custom fields. The only solution I found was to make adjustments to the theme function twentytwelve_entry_meta(); - but this won't work on a different theme, right?

  • I edited and added my use case above – Flow Jan 4 '13 at 6:26
  • I couldn't solve the issue yet, at least not satisfying(ly) enough. I keep checking into ways and tools to edit "This entry was posted in" independent from the theme files. Keep you updated. – Flow Jan 10 '13 at 11:00

If your code requires themes changes it belongs to the theme, usually the functions.php. In a custom child theme this is not a problem, in a plugin for everyone, it will be much harder. :)

The best option to get a theme more flexible: Ask the theme author to add a hook. Provide a real use case. If you don’t want t wait, add the hooks to your child theme. See also ticket #21506 Standard Theme Hooks.

Your use case – changing twentytwelve_entry_meta() – cannot be cross-theme compatible for a simple reason: Not every theme comes with a similar function. Some themes use author name and associated terms in different locations, others don’t show this data at all.

  • Hi, thanks for the reply. I can't really believe that I reached the need for a trac ticket, I guess I misunderstood something in developing. My idea is to create a plugin for me to add certain functions, to later be able to use on different themes. Isn't that also the idea of plugins? – Flow Jan 4 '13 at 6:15
  • 1
    @Flow There is rarely a need for custom hooks. Usually you can do what you want without changes to a theme. Tip: loop_start and loop_end. – fuxia Jan 4 '13 at 7:55
  • thanks a lot, I had a look at loop_start and loop_end. They don't quite fit what I need. – Flow Jan 4 '13 at 16:35

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.