0

I'm using Mooberry Book Manager which has a hook in it's grid

mbdb_book_grid_after_link

I've created a plug in so that I can show additional content in the grid, it's very basic

<?php
/*
Plugin Name: jw-book-enchance
*/
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
function addOptions($post_id){
     $post = get_post($post_id);
     echo $post_id;
}
add_filter('mbdb_book_grid_after_link','addOptions');
?>

however when I run this it gives me the post ids before the the plugin's content.

I'm not sure if this is an issue with the way the hook was implemented or if there is something I'm missing about how to do this.

here is a screenshot screenshot

1 Answer 1

0

You don't echo content from a filter, you return it. You should have:

function addOptions($post_id){
     $post = get_post($post_id);
     return $post_id;
}
add_filter('mbdb_book_grid_after_link','addOptions');

See: https://wordpress.stackexchange.com/a/113760/21376

4
  • That resulted in no output. at all
    – mcgrailm
    Jul 1, 2015 at 3:03
  • Then you may have an action not a filter, despite your using add_filter() instead of add_action() as would be correct for an action. If that is the case, the solution is going to be plugin specific and the question most likely off topic. You may not be able to do what you want.
    – s_ha_dum
    Jul 1, 2015 at 3:07
  • ok looking at the code in the plugin do_action('mbdb_book_grid_after_link', $mbdb_bookID, $mbdb_book_title, $image_src, $mbdb_book_grid_cover_height, $c); so it is an action
    – mcgrailm
    Jul 1, 2015 at 3:23
  • Then you're content is going to come out where the plugin let's it.
    – s_ha_dum
    Jul 1, 2015 at 3:34

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.