Tag Info

New answers tagged

0

I checked how ACF did it and tried it their way, worked for me. class Directory_Post_Type { public static $post_type = "directory"; public function __construct() { add_action( 'init', array( $this, 'init' ) ); add_action( 'admin_init', array( $this, 'admin_init' ) ); add_filter('post_updated_messages', array( $this, ...


1

get_stylesheet_directory_uri() returns an URL. The requested file is called like any other publicly available resource: without the context of the include statement. This is like opening the PHP file in a browser directly. There is no WordPress context, and the functions add_action() or add_filter() are not defined. Use get_template_directory() in parent ...


0

Errm, you can't. And more importantly, why would you want to? The whole point of hooks is to open up an API to other developers! You can use a singleton/static flags and/or private methods (called from a hooked public method) if you want to lock down how your plugin can be manipulated. static function myfunction_for_themes() { if ( ! self::$_themes_run ...


2

publish_post doesn't work for custom post types, the correct hook (action hook) is publish_{$custom_post_type}. You should use add_action() as this is an action hook. I also tend to make use of the transition_post_status hook which is a much more universal hook as it fires everytime a post's status is changed regardless. You can use $old_status and ...


0

The short answer is that there isn't one. WordPress templating consists mostly of raw PHP and Template Tags API. The API is more focused on outputting specific content, than producing specific HTML. As result the technique is pretty much unknown in WordPress development. It doesn't mean that you can't use one, but it's just not a convention developers ...


3

Looking at your code you are calling the function ghoolo_mango() by using the the wp actoin hook. This is fine but be aware that it will add your post everytime a page loads. The problem is that you are also calling the function ghoolo_mango() within the function itself - i.e. it will keep calling it over and over. To fix the problem, remove the line ...


1

Once a fucntion has been hooked to an action, the function will be executed every time the action is called (with do_action). To stop this, the action should be removed. See remove_action: function do_entry() { if ( get_the_title() ) { add_action('loop_entry_before', 'function_that_adds_h2_structure'); } else { ...


-3

See flush_cache function in wordpress-seo/frontend/class-frontend.php Find this line of code $content = str_replace( $this->debug_marker( false ), $this->debug_marker( false ) . "\n" . '<title>' . $title . '</title>', $content ); Replace with $content = str_replace( $this->debug_marker( false ), '<title>' . $title . ...


0

The include of custom code via theme is different from the including via plugin. It is important, that you add a hook to include your custom source inside the plugin, like after_setup_theme, maybe with a low priority, after the default theme init his code.


0

Because I was trying to make the redirect happen using shortcode in the registration and I didn't get the answer which can delay the redirect until I add custom textarea fields date to user profile page before this step $userID = wp_insert_user( $userDataArr ) , I have no user ID yet, so I can't do update for unknown user id after it the redirect happens ...


4

The function checks your version of WP for possible updates. It appears that there is a transient in the database named 'update_core', so it's stored in the $wpdb->options table as '_site_transient_update_core'. The value of that transient is a serialized object that has information, I'm not an expert on wp_version_check, but it uses that transient to keep ...


-1

Yes there is. Create a function. Hook it by adding it to an action. Use one of the following actions to hook it to: add_option_(option_name) Runs after a WordPress option has been added by the add_option() function. Action function arguments: option name, option value. You must add an action for the specific options that you want to respond to, such ...



Top 50 recent answers are included