wordpress

I am watching some tutorials at Linda.com on theme modification for wordpress spacifically using THE GENESIS FRAMEWORK for wordpress and the associate Child theme from studiopress.

I am following along with the video tutorial where the author explains how to use add_action and remove_action in the functions.php. I take the codes right from where she specifies (post.php) and i place the code where she specifies (functions.php) to do very simple excercises to "add" and to "remove" code from a page or post but none of the "add_action" or "remove_action" codes work. Only the "add_filter" works in my functions.php file.

I wonder what configuration I need to do for "add_action" or "remove_action" to work in my functions.php file as the author does not explain anything prerequisite for these exercises.

Hi @Charleshaa here is one example:

Example the first exercise is to REMOVE the post title. (Obviously there is NO reason to do this but it is just an exercise to show the use and function of the add_action remove_action)

So she says go to post.php and find this piece of code:

    add_action( 'genesis_entry_header', 'genesis_do_post_title' ); 

and place it in the functions.php at the very bottom but modify it like so:

    remove_action( 'genesis_entry_header', 'genesis_do_post_title' );

Then she goes to the post as the public sees it and in fact the post title is gone in her video but having done this exact same action after I refresh (f5) my browser my post title is still there.

This is one example.


add_action and remove_action do not need any configuration.

You need to find the right action hook for your purpose, and anywhere in functions.php, just write add_action('the_hook_you_want', 'the_function_you_want_to_call') .

It also takes 2 other arguments, the first one is the number of arguments the_function_you_want_to_call takes in, and the second is the priority, you can leave that at 10 .

I almost never used remove_action , since you probably want to do more, and not prevent wordpress from doing what it does.

If you are not sure of what hook to use, you can look for all the do_action() in your wordpress code.

Could you post some code and explain what exactly you are trying please ?

链接地址: http://www.djcxy.com/p/57348.html

上一篇: 过滤器内部功能不起作用

下一篇: WordPress的