Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

1 Answer

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.

share|improve this answer
    
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. –  toscho 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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