I’m having trouble calling functions using “add_action”. here is my process:
I add the “muimedia_post_video” like so in my functions.php (the last add_action):
/* Posts */
// muimedia_before_post_loop
add_action( 'muimedia_post_before_entry_content', 'muimedia_post_entry_meta', 10);
add_action( 'muimedia_post_entry_summary', 'muimedia_post_entry_summary', 10);
add_action( 'muimedia_post_after_entry_content', 'muimedia_post_entry_data', 10);
add_action( 'muimedia_post_no_results_not_found', 'muimedia_post_no_results_not_
found', 10);
add_action( 'muimedia_after_post_loop', 'muimedia_post_pagination', 10);
add_action( 'muimedia_post_video', 10);
I make the actual muimedia_post_video action function (in contentextensions.php):
/* muimedia_post_video */
if ( !function_exists( 'muimedia_post_video' ) ) {
function muimedia_post_video() {
?>
<div class="video-entry-summary">
<?php if (has_post_thumbnail()){ ?>
<a href="<?php the_permalink() ?>"
title="<?php the_title_attribute( array('before' => esc_attr__( 'Permalink:
', 'muimedia' ), 'after' => '')); ?>" rel="bookmark"><?php the_post_thumbnail();
?></a>
<?php } ?>
<h1 class="entry-title"><a href="<?php the_permalink(); ?>"
title="<?php the_title_attribute( array('before' => esc_attr__
( 'Permalink: ', 'muimedia' ), 'after' => '')); ?>" rel="bookmark">
<?php the_title(); ?></a></h2>
<div class="entry-meta">
<span class="meta-date"><?php echo get_the_date(); ?></span>
</div>
<?php the_excerpt(); ?>...
<div id="disquscomments"><a href="<?php comments_link(); ? >#disqus_thread">
Comments</a></div>
</div>
<?php
}
}
Then I call the function in any php file like like so:
<?php do_action('muimedia_post_video'); ?>
I don’t know why, but this doesn’t show any posts. 🙁 If I use an action that came with the theme like “do_action(‘post_entry_summary’)” it shows all the posts for the respective category fine… but by theory it should work with my custom do_action as well because all I did was copy and pasted the post_entry_summary code, changed the name of it and added a new do_action in my themes functions.
It’s really important that I get this working and I have no idea why my own custom functions aren’t working. I’ve done everything correctly to my knowing. Any help would be appreciated so so so so so, so so…. so (so) much! 🙂
Changing:
to:
did the trick. 🙂
add_action need following arguments….
So in your last functions you did not add the function. You need to add that functions to make it work.
Reference: http://codex.wordpress.org/Function_Reference/add_action