How to get an Action Hook to work as expected?
-
Good Afternoon,
The below block of code is used to display the parent page and submenu pages in list format. Rather than pasting this on each of my different templates, I would like to paste it once in say the function.php theme file and then use an action hook single line of code to call it on each of the templates.
I understand the idea of how this works but in practice it doesnt for me.
<?php
if($post->post_parent)
$children = wp_list_pages(“title_li=&child_of=”.$post->post_parent.”&echo=0″);
else
$children = wp_list_pages(“title_li=&child_of=”.$post->ID.”&echo=0″);
if ($children) { ?>-
<?php echo $children; ?>
<?php } ?>
In the functions.php file I added the code with
function mycustom_menu() {
in front of it, and}
after it. And yes their already is a function.php file with code in it, so all of this code above is between and initial opening php and closing php.Then in my template where I want to call it I put:
<?php do_action('mycustom_menu'); ?>
But it did not display. Is their a better way to go about this, or different syntax needed? Thanks!
Cheers,
Christopher
- The topic ‘How to get an Action Hook to work as expected?’ is closed to new replies.