我在使用「add_action」調用函數時遇到問題。這裏是我的過程:通過「Add_Action」不工作的自定義函數
我添加 「muimedia_post_video」 像這樣在我的functions.php(最後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);
我做出實際行動muimedia_post_video功能(在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
}
}
然後我調用函數中的任何PHP文件一樣,像這樣:
<?php do_action('muimedia_post_video'); ?>
我不知道爲什麼,但這不顯示任何帖子。 :(如果我使用與「do_action('post_entry_summary')」這樣的主題一起使用的動作,它會顯示相應類別的所有帖子...但是從理論上講,它應該與我的自定義do_action一起工作,因爲我所做的是複製和粘貼post_entry_summary代碼,改變了它的名字和我的主題功能,增加了新的do_action。
這真的很重要,我得到這個工作,我不知道爲什麼我自己的自定義功能不工作。我已經正確地做了一切我知道任何幫助將非常感激這麼這麼這麼這麼這麼,這麼這麼....所以(所以):)