The K2 theme provides a number of additional hooks into the template. If you’re handy with PHP you can easily add any manner of arbitrary content to these 10 regions. For everyone else, there is K2 Hook Up.
This plugin provides an options screen with each unique hook exposed as a simple text box. Insert any HTML, CSS, or JavaScript that you like, and click submit and it will be instantly published to that region of your template.
Which Hooks are available?
- Body Top
- Right after the opening <body> tag
- Before Header
- between the <div id=”page”> and <div id=”header”> blocks
- Header
- Below the <p class=”description”> block
- Header Menu
- Inside the <ul class=”menu”> block. Use this one to add <li> items to your navigation
- Before Content
- Before all of the content in <div class=”content”> (this includes the sidebars)
- Primary Begin
- Before the Rolling Archives block (and after the notices div)
- Primary End
- After the dynamic content (and before the closing tag for the primary div)
- After Content
- After all of the content in <div class=”content”>
- Before Footer
- Before the start of the <div id=”footer”> block
- Footer
- Inside the <div id=”footer”> block, before the powered by links
For more info, and to see how the hooks are integrated into the mark up, check out the K2 CSS and Custom CSS wiki.
Using WordPress 2.6.3. and K2 RC-7
I keep getting:
Warning: call_user_func_array() [function.call-user-func-array]: First argumented is expected to be a valid callback, ‘flaresmith_load_translation’ was given in /home/fruity/public_html/wp-includes/plugin.php on line 311
Addendum to previous comment… I am also using FeedBurner FeedSmith plugin. Maybe there’s a conflict with it?
I activated your plugin and got this:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘flaresmith_load_translation’ was given in /home/twenty/public_html/wp-includes/plugin.php on line 311
I am very eager to start using this, it is exactly what I have been looking for!
fruityoaty,
That’ll teach me to copy code from another plugin! I just committed a fix for this as v0.6. Upgrade to that, and you’ll be fine. It should happen semi-automatically since you’re using WP 2.6.3.
Thanks for pointing that out!
- Eric Marden
Thanks for the quick fix. Works great.
Wow, I must say… this is a great plugin. Having fun trying it out. Thank you very much for sharing your work.
My pleasure. Have fun, and spread the word. K2 is love.
-e
Eric. Interesting plugin you got here. I am thinking about all sorts of possibilities with this. So far, I am enjoying my experience with K2. Keep up the great work!
Thanks, Bensan.
I’m going to be adding php support to K2 Hook Up later today, which will further blow the doors off this great theme.
I have another plugin I’m starting to draw up plans for, that will require being able to print out WordPress template tags in the hooks that this plugin targets, so the two will go hand in hand once they are both finished.
Stay tuned,
- Eric
v1.0 of K2 Hook UP now supports inserting PHP code. You can read more about this update on the blog.
How do you get rid of the 2 post titles that show up above and/or below the single post entries without screwing anything up? Is it in the single.php file?
I just installed.. wow.. thanks!
Ryan,
You’ll have to link me to a page this is happening on so I can see what you’re doing. Nothing in my plugin should be causing double titles.
-e
David,
You’re welcome. I think K2 Hook Up makes K2 an even smarter choice in themes for WordPress.
-e
Eric,
I’m not talking about double titles, I’m referring to the titles that link to other posts and appear in smaller font above the single page titles
You can do that with CSS. Put this in your custom style sheet:
.nav-previous, .nav-next {
display: none;
}
This will just hide the links. You can also target the id: #nav-above and #nav-below and hide the whole containing box too.
Let me know if you need more help than that.
-e
Eric,
That’s exactly what I needed. Thanks for the help.
Hello Eric, I would like to wrap some of my sidebar widgets into divs for css styling – is there a wp or k2 hook that I can use?
(I am currently hacking k2.php to get it done but I would like to use a functions.php file in my k2 style’s directory instead)
Btree,
I can’t think of any hooks that would be useful in this regard, but there still may be a solution. The sidebars are wrapped in divs that can be styled pretty easily. What are you trying to do that you need more divs for?
-e
btree:
You would use the filter “dynamic_sidebar_params”.
Hi there,
I’m using WordPress 2.7 and K2 RC-7 and it works beautifully. I’ve been looking for something like this for a while. I’ve already started to ‘pimp up’ my website with your plugin. Amazing work by the way! I’m amazed I can now tweak my themes without worrying about the upgrade to a new K2 or a new wordpress. Cheers and keep up the good work!
Is is possible to add edit in place via flutter plugin with the k2 hooks plugin? I need to add : <h2 class=”"> And :
<div class=”">
to theLoop.php i think…
I’m looking at Flutter now and not seeing any special documentation for enabling edit-in-place.
However, if you need to get something into the loop, I have another plugin which may do the trick: In The Loop.
-e
Very good…muito bom
I’m glad you like it. Você é bem-vinda.
I think your plugin is awesome because it prevents modifying K2 files with every update of the theme. The only thing I think it should be added is a hook for adding html tags “Before Body”, right at head tag.
If I want to add a favicon code for example, it can be done after the body tag, but it’s not HTML compliant, so the only way to do it is inside the head tag.
Can it be done??
K2 Hook Up uses the hooks that K2 publishes inside its theme, so to do it exactly as you are suggesting would require adding a new hook (and hence modifying the theme files). There is wp_head that I could target as well for this, but for favicons, I usually use this plugin: Favicon Manager. You may already have one, but I wrote a tutorial on creating favicon.ico files from PNGs recently that you may be interested in, too.
Thanks!
Hi there,
I just installed your plugin and added a couple of hooks, one in the header and one at the bottom before the footer. Nothing is showing up.
The one on the header is a (adsense google add) that’s been in use in all my posts, I just put it in the header to see if it works but I could not get it to work.
the one (before the footer) is just a simple html code that is also in one of the wdigets for a link to a page on my site (tasty cooking) link. you can see it on top of the side bar.
just wondering if I did anything wrong, it seems fool proof that there is not much I can do wrong, put the script in the windows and update????
Have you tested it with just some plain text, to ensure that *something* shows up? Which exact hooks are you using?
Hi Eric,
I am using version 1.1.1,
I tried using just plain text, still nothing showed up.
thank you
Which version of K2? The hooks were added in some recent versions.
Eric,
I am not sure I understand your comment??? in my admin area it tells me that I have (k2 hook up version 1.1.1)
I just installed this plugin today, there is no other versions???
The version of K2 itself. You can find that under Appearance > Themes in WP-Admin
AHH,
Now I think I understand, I thought your were asking for k2 hooks version, you are asking for the k2 theme. So K2 hooks only work with k2 themes, if so then that explains why it’s not working. I don’t have a k2 theme.
I thought this is just a plugin that would work with wordpress independent of the theme.
thank you
so is there any cool k2 theme, you would recommend
K2 is more of a theme framework, but can be easily customized via CSS and the built in Theme Options and includes many other features non-developers seem to get a lot of mileage out of.
You can learn more about it here: http://getk2.com
Check out In the Loop for a similar plugin of mine that does work with any theme.
Is there a way to make the coding on the header for the navigation drop lower? For instance on this site http://www.maverickmlmcoach.com I need the navigation to be a step lower so it is not so crushed up against the header. Also where do I go in the coding to add another link to the navigation bar as I cannot find this piece of coding anywhere.
Thank you.
Rebbekah
You’ll want to create a child theme to take care of these issues. The basics are explained on the K2 Wiki.
You can manage the placement of the navigation by using CSS. Take a look at the defaults in k2/style.css for ul.menu, then tweak as you see fit in your child theme’s style.css style sheet.
As for adding a link, what you’ll need to do is copy k2/blocks/k2-header.php to your child theme in the same ‘location’ (i.e. blocks/k2-header.php). Any changes you make in your child theme copy will override those in k2’s copy (this is how child themes work). It should be relatively obvious what you’ll need to change, but like the styles, start with the default code and change just what you need to get it the way you want it.
-e
Just installed the K2 Hook Up plugin version 1.4. I have k2 rc8. When I press the Configure Settings link I get “No input file specified. “. My child theme is my_k2. I have a copy of blocks/k2-header.php under my_k2. In fact, I have a complete copy of blocks under my_k2.
Do I have to specify an input file? Where?
The link in on the plugin list was just broken. The Options Page for K2 Hook Up can be found under the “Appearance” section of wp-admin. I have just submitted a fix for this link to the plugin repository, and you should be notified of the update shortly via WordPress’s auto-update feature.
Thanks for telling me about this bug.
-e
Thanks for your prompt response.
Fixed the offending link to Configure Settings
It is working ok now.
Juan
that link will only work for your set up. if you upgrade to the latest (v 1.4.2) a fix that should apply universally is in that version. Either way, glad you’re back in business with K2 Hook Up.
-e
Hi author, I want translate your plugin to russian language. Please tell me Your email, simply reply me to email. Thanks
Thanks for doing this. Let me know how I can test it and I will be happy to release it.
Thanks again!
I have asked this question on the K2 support forum…
I am using K2 v1.02 on a self hosted Wordpress blog and I want to be
able to insert Google ads between posts on my Wordpress blog
http://www.osd-uk.com/protoolsformedia as I had on my Blogspot blog
http://protoolsformedia.blogspot.com.
I found a guide that would appear to do this at…
http://weblogs.about.com/od/wordpresstutorialstips/ss/AdSenseBtwnPost...
and the first thing they ask is to insert
immediately before on the Index Template
page in the theme editor. However I cannot find in the K2 theme editor!
How can I insert ads between my posts in K2.
Someone recommended your plug-in which looks as if it can do what I want. But my question is which point do I put the Google Adsense code so an ad appears between posts and I would prefer an ad didn’t appear between every post. There is a setting on Blogspot sites that restrict the ads to no more than 3 on a page and I would like to mirror something similar on my Wordpress blog.
Thanks,
Mike.
Mike,
You’d have to employ a bit of Custom PHP to make this work, and would probably be easier to accomplish in a K2 child theme, so you can over ride it at the template level. Doing this would probably obviate the need for my plugin.
It doesn’t seem that template_primary_end (what I need) works. I’m running Wordpress 2.9.1, K2 1.0.2, and K2 Hookup 1.5.1.
template_primary_end appears to be missing from single.php, possibly others.
Am I missing something?
The template_primary_end hook appears after a list of posts.
Use template_entry_foot for the hook that runs after each blog post.