Tag Info

New answers tagged

0

"Category" is a taxonomy. What you're looking to do is limit the number of "terms" Depending on your goal (I think you want to show comingled attachments and posts in one giant list/interface?) - what you could do is create a new taxonomy, call my_attachment_terms and then add terms to that taxonomy and label them appropriately, **utilize the wp_insert_term ...


3

<?php class someClass { public function __construct($options = null, $initialize = true, $error_messages = null, $path, $qnty) { //construct what you see fit here.... } //etc.. } // Action listener add_action( 'action_name', create_function('', "new someClass(implode(',',func_get_args()));"), 10, 5 // IMPORTANT, ...


0

I finally figured out a solution using query vars to pass the status message to the next page so that it can be used in post_updated_messages. Here's a simplified version of what I did, with all the function names changed for simplicity's sake to focus on the problem at hand; First, added the value I needed to the $_POST var; function ...


0

Every system keeps evolving till the end; Same goes for WordPress. I think reason why post action hooks have evolved much then user related action hooks is because community have been focused on using posts related functionality more then users related stuff. As we all are aware of the fact that; A single author publishes multiple posts Anyways ...


0

I believe you can get the same result what you are looking for with filter hook post_updated_messages. You just need the post id for the confirmation thing that you are doing which you can do over here as well using $_GET['post'] which contains your post id. Here is function which will do the thing. function your_modified_message( $messages ){ ...


0

For removing an action hook you should use the same action name, callback name and the priority that was used to add a action in parent theme. And register it on init add_action( 'init', 'remove_action'); function remove_action() { remove_action( 'woocommerce_before_shop_loop','storefront_sorting_wrapper',9 ); } Read about remove_action


11

I don't think there exist one, but you could create your own, wpse_empty_trash, with something like this: /** * Add a custom hook 'wpse_empty_trash' */ add_action( 'load-edit.php', function() { add_action( 'before_delete_post', function ( $post_id ) { if( 'trash' === get_post_status( $post_id ) && filter_input( ...


3

wp_loaded is called long, long before the post content is fetched. Put that code into a plugin. Also, you shouldn't echo anything that early. The HTTP headers aren't sent yet on wp_loaded, so you will get the Headers already sent error, and your user authentication will not work: you cannot log in anymore.


0

in my opinion this is a valid scenario, its a solid way to offer your plugin as an interface to other plugins but still each plugin can be active or inactive and wp will not crash (in comparison to calling a method directly which may not exist because a plugin was not activated i solved it by passing an object, like so: // define action with param for ...


0

if you create your own hook, here is example. // lets say we have three parameters [ https://codex.wordpress.org/Function_Reference/add_filter ] add_filter( 'filter_name', 'my_func', 10, 3 ); my_func( $first, $second, $third ) { // code } then implement hook: // [ https://codex.wordpress.org/Function_Reference/apply_filters ] echo apply_filters( ...


0

answer ^^ add_action( 'load-edit.php', function() { global $typenow; // Not our post type, bail out if( 'community' !== $typenow ) return; // Administrator users don't need this, bail out if( current_user_can('add_users') ) return; // Only the Mine tab fills this conditions, redirect if( !isset( $_GET['post_status'] ) && !isset( ...


0

Try this way: add_action( 'save_post', 'myFunc'); function myFunc(){ if ($post->post_type == 'cpt' ) { // do action here } OR add_action( 'save_post', 'myFunc'); function myFunc(){ if ( 'cpt' == get_post_type() ) { // do action here }


0

As @Pieter said, you can use transition_post_status: function wpse_187997_job_status( $new_status, $old_status, $post ) { if ( $post->post_type === 'job' && $new_status !== $old_status ) { // Post type "job" and status has changed } } add_action( 'transition_post_status', 'wpse_187997_job_status', 10, 3 );


2

When you send an AJAX request, wp-admin/admin-ajax.php is called, not your template file. This separate request has no knowledge of all existing code in all existing templates, because they aren’t even included. What is included: the theme’s functions.php and plugin files. This is why your callback works in a plugin. As a rule of thumb: templates should ...


0

The first thing to do is ensure that your template's header.php and footer.php files contain, respectively, calls to wp_head() and wp_footer(). Without those functions, no actions hooked to wp_head / wp_footer will work.


1

I understand, that you add the possibilties for developers to change the html, typical a template part. That is the point, that I think you should use the default functionality for this job. get_page_template() can be overridden via the page_template filter. A simple example for the dev to change your templates from your plugin. add_filter( ...


1

You cannot insert the do_action() inside the class like that, it's gonna give you a fatal error. Instead you could use an array $skins to store all the skin functions (as closures), and the magic method _call() to call them: class skinclass { private $skins = array(); function __construct() { $this->skins = apply_filters( 'add_skin', ...


0

What about using save_post or wp_insert_post hook, both have @param     int               $post_ID     Post ID. @param     WP_Post     $post          Post object. @param ...


4

The name of the current hook is always current_filter(). Despite its name, this function returns the name of actions too. Usage example: Move the textarea in a comment form. The current priority is: key( $GLOBALS['wp_filter'][ $hook ] ).



Top 50 recent answers are included