在wordpress中从init中删除一个动作(Remove an action from init in wordpress)

编程入门 行业动态 更新时间:2024-10-26 02:31:13
在wordpress中从init中删除一个动作(Remove an action from init in wordpress)

我有一个主题定义了一个新的帖子类型,但我想在子主题中删除该功能:

父母主题功能:

add_action('init', 'portfolio_register'); function portfolio_register() { //post type definition }

儿童主题功能:这是我试过的,但它不起作用。

function child_remove_parent_function() { remove_action( 'init', 'portfolio_register' ); } add_action( 'init', 'child_remove_parent_function', 15 );

任何人都知道我做错了什么? 提前致谢。

I have a theme that defines a new post type but I want to remove that function in the child theme:

PARENT THEME FUNCTION:

add_action('init', 'portfolio_register'); function portfolio_register() { //post type definition }

CHILD THEME FUNCTION: This is what I tried but it is not working.

function child_remove_parent_function() { remove_action( 'init', 'portfolio_register' ); } add_action( 'init', 'child_remove_parent_function', 15 );

Anyone has an idea of what am I doing wrong? Thanks in advance.

最满意答案

在子主题function.php中添加操作之前尝试此代码

<?php remove_action( 'init', 'portfolio_register' ); ?>

要么

<?php add_action( 'after_setup_theme','remove_portfolio', 100 ); function remove_portfolio() { remove_action( 'init', 'portfolio_register'); } ?>

try this code before add action in child theme function.php

<?php remove_action( 'init', 'portfolio_register' ); ?>

or

<?php add_action( 'after_setup_theme','remove_portfolio', 100 ); function remove_portfolio() { remove_action( 'init', 'portfolio_register'); } ?>

更多推荐

本文发布于:2023-07-26 00:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1268308.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动作   init   wordpress   Remove   action

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!