WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using a plugin which has the following function: See end of question.

And I've created a hook in my template file:

<?php custom_hook(); ?>

And this is what I have in my functions.php

function custom_hook() {
    echo 'Custom Hook works!';

add_action('custom_hook', 'wnw_overall_rating_comments', 1);

I am curious, as why this isn't loaded. I have even edit the add_action to the plugin to see if my filter works,


But no luck.

Am I missing something here?

function wnw_overall_rating_comments($content)
    global $post,$rating_table_name,$wnw_multi_rating_table,$multi_rating_image_on,$multi_rating_image_off,$multi_rating_image_half,$wpdb;

    if($post->type != 'page')
        //some function

        return $content.$rating_value;
        return $content;    

share|improve this question
This answer explains how you should work with hooks/filters and themes/plugins. In short: Does the string from custom_hook then echo in your template? Btw: The add_action() call should reside in your plugin. Not in the theme. – kaiser Oct 14 '12 at 19:33
You are adding to custom_hook in one code snippet and the_content in another... So which one is it? – Rarst Oct 14 '12 at 19:33
Dear @kaiser, thank you for the article. I have been reading and trying different method to solve this. And following the Example 1. What I do now is adding this on the theme file <?php do_action('custom_hook'); ?> And add the action add_action('custom_hook','wnw_overall_rating_comments'); on the plugin. That didn't work as it should. I'm trying to understand why it didn't pulled. – Mohd Rafie Kamaruzaman Oct 16 '12 at 13:26
Because you need to echo... And please answer @Rarst question. Thanks. – kaiser Oct 16 '12 at 13:31
@Rarst What I am trying to do is to pull the function from the plugin and execute it elsewhere in the theme. The current situation, the plugin execute the code at the the_content and I want it to execute at the custom_hook But which bit should I echo as you suggest? Pardon my lack of knowledge. – Mohd Rafie Kamaruzaman Oct 16 '12 at 13:47

You're simply missing the return print or echo statement (instead of just return).

share|improve this answer

Your Answer


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.