3

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?

2
  • I edited and added my use case above Commented Jan 4, 2013 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. Commented Jan 10, 2013 at 11:00

1 Answer 1

3

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.

Update
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.

3
  • 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? Commented Jan 4, 2013 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. Commented Jan 4, 2013 at 7:55
  • thanks a lot, I had a look at loop_start and loop_end. They don't quite fit what I need. Commented Jan 4, 2013 at 16:35

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.