2015-04-21 25 views
1

嗨,大家好我想學習使用PHP過濾器WP環境來執行此:在Php過濾器如何用別的東西替換一些代碼?

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

過濾器除去這個學分,並添加只是一個版權信息......我該怎麼辦呢?

<?php 
/** 
* The template for displaying the footer. 
* 
* Contains the closing of the id=main div and all content after 
*/ 
?> 

    </div><!-- #main .site-main --> 

    <?php get_sidebar(); ?> 

    <footer id="colophon" class="site-footer" role="contentinfo"> 
     <div class="social-menu"> 
      <?php if (has_nav_menu('social')) { 
       wp_nav_menu(array('theme_location' => 'social', 'container' => 'false', 'menu_class' => 'menu-social')); 
      } ?> 
     </div><!-- .social-menu --> 
     <div class="site-info"> 
      <?php do_action('glow_credits'); ?> 
      <a href="http://wordpress.org/" title="<?php esc_attr_e('A Semantic Personal Publishing Platform', 'glow'); ?>" rel="generator"><?php printf(__('Proudly powered by %s', 'glow'), 'WordPress'); ?></a>. 
      <?php printf(__('Theme: %1$s by %2$s.', 'glow'), 'Snaps', '<a href="http://glow.com/" rel="designer">glow</a>'); ?> 
     </div><!-- .site-info --> 
    </footer><!-- #colophon .site-footer --> 
</div><!-- #page .hfeed .site --> 

<?php wp_footer(); ?> 

</body> 
</html> 

我知道如何做到這一點:

function test_new_action() { 
    echo 'Howdy'; 
} 
add_action('glow_credits','test_new_action'); 

但犯規替換...

+0

你可以有多種功能掛鉤到一個動作。您將需要刪除原有的功能才能正常工作的功能。搜索你的主題文件glow_credits,然後你可以找到相關的功能。您也可以註釋掉正在調用函數的add_action函數。 – kel

回答

0

可以使用remove_filter()解開現有的功能 - 你只需要找到出了名顯示信用的功能。

EG:如果函數被調用display_credits那麼你可以鉤住自己之前在功能使用:

remove_filter('glow_credits', 'display_credits');