WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can't Get "add_action" To Work :( (2 posts)

  1. ianbee
    Member
    Posted 1 year ago #

    I'm having trouble getting the "Add_action" function to work.. here is my process:

    I add the muimedia_post_video like so (at the bottom):

    /* 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);

    Here is the actual muimedia_post_video action:

    /* 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 it like so:

    <?php do_action('muimedia_post_video'); ?>

    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 paste the post_entry_summary code, changed the name of it and added a new do_action in my themes functions. WHY ISN'T THIS WORKING!!?? :(

    If this doens't make too much sense here is the simplified version.

    My theme gets functions / actions like so:

    contentextensions.php => functions.php => any file i call it in.php

    So I have a bunch of functions in my contentextensions.php like post_entry_summary, post_entry_meta, "page_title" etc. Then in the functions file I get the function by calling it like soo.. add_action( 'muimedia_post_entry_summary', 10); then in my php header file I could call the function like so: <?php do_action('muimedia_post_entry_summary'); ?>

    I hope this make sense. It's really important to 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! :)

  2. ianbee
    Member
    Posted 1 year ago #

    Figured it out myself. Thanks for the help guys...

Topic Closed

This topic has been closed to new replies.

About this Topic