Tag Info

Hot answers tagged

6

Remember Apple's "Goto Fail"? Similar situation: Your code actually does this, when indentation is corrected: foreach ( $post_types as $post_type ) remove_meta_box('trackbacksdiv', $post_type, 'normal'); remove_meta_box('postcustom', $post_type, 'normal'); remove_meta_box('authordiv', $post_type, 'normal'); remove_meta_box('postexcerpt', ...


2

Please note, this should not be the accepted answer, this is only an extension to the answer given by @ungestaltbar, so please, @willow, accept the other answer, and if you deemed my answer useful, simply just give me an upvote :-) The biggest issue that should solve your problem have been discussed in the other answer, but I would like to point out some ...


2

Newer New solution: function wpse153622_transition_solution( $new_status, $old_status, $post ) { if ( $new_status != $old_status && 'publish' === $new_status && 'my-solution' === $post->post_type ) { update_post_meta( $post_id, 'my_json', 'json' ); } } add_action( 'transition_post_status', ...


1

This is a wild guess, because you didn't provide (parts of) your template. Anyway, most probably (if lessons.php is a full template) there is get_header(); somewhere at the beginning of your template file. If you put the very code you posted in your question before this it will render, as the wp_head action is still to come. // EDIT My suggestion, however, ...


1

First of all, the_content is a filter hook and not action. Secondly, it will only work when post content will be access on your site front end. You can probably make use of global variables instead. e.g. $options = get_option( 'wpglobalsettings' ); and then use wherever you want to access as follows - global $options;


1

I thing you are missing the context. $GLOBALS['hook_suffix'] is available on any action fired after admin_init. Now, if you tried something like add_action( 'admin_footer-'. $GLOBALS['hook_suffix'], 'myfunction' ) outside of any function, you are not going to get anything. But if you do it - add_action('admin_menu', 'do_hook_to_footer') and put the ...


1

Turns out you have to add some special function sniffing in the configuration of the pot file (from http://www.cssigniter.com/ignite/wordpress-poedit-translation-secrets/): __ _e __ngettext:1,2 _n:1,2 __ngettext_noop:1,2 _n_noop:1,2 _c _nc:4c,1,2 _x:1,2c _nx:4c,1,2 _nx_noop:4c,1,2 _ex:1,2c esc_attr__ esc_attr_e esc_attr_x:1,2c esc_html__ esc_html_e ...


1

There are two flaws in the code that I can see. The first one is a bug in this code if($post->post_type != 'product') If no post exists, you get the following error Notice: Trying to get property of non-object... This can be fixed by first checking if a post isset if(isset($post) && $post->post_type != 'product') Secondly, ...


1

In WordPress 'do_action' is used to add an action hook in a plugin, which then can be used to hook our own function with plugin. Check Codex for more details: Hooks API WordPress To add your own function you will have to do the following: add_action('groups_screen_group_request_membership', 'your_function_callback'); function ...


1

The way you do it is fine. Also have a look at how Tom McFarlins WordPress Plugin Boilerplate does it: if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { require_once( plugin_dir_path( __FILE__ ) . 'admin/class-plugin-name-admin.php' ); add_action( 'plugins_loaded', array( 'Plugin_Name_Admin', 'get_instance' ) ); ...


1

I think the path to the image is wrong, use get_stylesheet_directory_uri() to retrieve the style.css path. If this isn't it let me know and I will take a closer look. I just dug out an example which worked for me in the past: function my_login_logo() { ?> <style type="text/css"> body.login div#login h1 a { background-image: ...


1

The $tag is used as a key in an array, so it is converted to either a string or an integer. There is no maximum size for strings, the available memory is the only real restriction. The size of an integer depends on the platform: The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits ...


1

I always thought that the memory size was the limit for the string length, but according to the PHP documentation: string can be as large as up to 2GB (2147483647 bytes maximum) There is also the maximum allowed memory size (memory_limit) for the PHP script, to consider. Testing: Do not perform this on a production server: You could always use the ...


1

I was able to add / remove terms from a post type if it was published by using the transition_post_status hook. I've adapted your question to my solution below: function run_when_my_solution_published( $new_status, $old_status, $post ) { global $wpdb; if($post->post_type == 'my-solutions' && $new_status == 'publish'){ ...



Only top voted, non community-wiki answers of a minimum length are eligible