0
Guys good night, I need to run a wordpress function whenever a post is included, deleted, edited and turned from the recycle bin. Someone can help me I don’t know how to do it.
Thank you.
0
Guys good night, I need to run a wordpress function whenever a post is included, deleted, edited and turned from the recycle bin. Someone can help me I don’t know how to do it.
Thank you.
0
Are you looking for actions. With them, you can attach methods that you define to certain "events" that occur in WP. For example, if you put, in your functions.php
the code
add_action( 'admin_init', 'init_admin_custom_css' );
function init_admin_custom_css(){
add_editor_style( get_stylesheet_directory_uri().'/css/meu_css.css' );
}
the WP will insert this .css
on the editor screen, every time you enter the administration menu (i.e., the action admin_init
). In your case, to perform an action every time a post is edited, for example, you can do
add_action('edit_post', 'minha_funcao');
and define
function minha_funcao(){
.
. #seu código
.
}
Behold here a list with the action
s that WP makes available, and choose them according to your need. In this part from Codex, you can observe the wp_insert_post
, that will be part of your code. Read more about the method add_action
, its peculiarities and its parameters here.
P.S. All 4 links are from Codex, which I strongly recommend reading.
Browser other questions tagged wordpress
You are not signed in. Login or sign up in order to post.
Post the code you’ve already made.
– Ricardo
start by searching here: https://codex.wordpress.org/Function_Reference/do_action
– Daniel Omine
@Ricardohenrique I think he could not build any code, he says in the post that he does not know how to do it.
– Florida