Articles of actions

Is it good practice moving the main stylesheets after the plugin styles?

currently I deleted the ‘classic’ hardcoded main /styles.css from header.php and enqueued it from a wp_enqueue_scripts action. Basically, the loading order in header I currently want (and have) is: [plugin styles] [main theme styles] [page-specific styles] [jquery] So my current code is: add_action(‘wp_enqueue_scripts’, ‘add_scripts_and_styles’, 11); // 11 so they load after plugins function add_scripts_and_styles() { […]

How to access page variable inside action hook

I have an action hook which simply displays a contact form for signup: add_action(‘woocommerce_single_product_summary’,’add_product_signup’, 10, 2); function add_product_signup() { do_shortcode(‘[contact-form-7 id=”20709″ title=”Product Sale Notification Signup”]’); } This works ok BUT… I want to only show the form if the product is NOT on sale. How can I access the ‘on_sale’ variable to test for true/false […]

How to register custom post types in a plugin?

I’m using toscho’s Plugin Class Demo code as a foundation for a plugin I’m developing. Amongst other things, my plugin registers a custom post type. public function plugin_setup() { $this->plugin_url = plugins_url( ‘/’, __FILE__ ); $this->plugin_path = plugin_dir_path( __FILE__ ); $this->load_language( ‘myplugindomain’ ); // more stuff: register actions and filters add_action( ‘init’, array( ‘MyPluginClass’, ‘register_my_post_types’ […]

do_action Nested List

I have a plugin with two custom post types – Projects and Tasks. In the plugin, you can assign tasks to projects. So, for example you might have a “Website Design” project with Tasks “Purchase Domain Name”, “Customize Theme”, “Add Content”, etc. What I’m trying to do is create a list of projects, and create […]

Get Taxonomy name from “registered_taxonomy” hook

I am using add_action to run a function after a taxonomy is created. Everything works but I can’t figure out how to grab the taxonomy name. I figured $args->name would be the way to go but it is not working, it is not returning anything. function test( $taxonomy, $object_type, $args ) { $catname = $args->name; […]

Form action unfamiliar

I am refactoring some code in the header.php: <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”> <html xmlns=”” <?php language_attributes(); ?>> <head profile=”″> <meta http-equiv=”Content-Type” content=”<?php bloginfo(‘html_type’); ?>; charset=<?php bloginfo(‘charset’); ?>” /> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <title><?php bloginfo(‘name’); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title> […]

the_post hook is not firing for me

I have a super simple requirement here. I have added a meta field to all posts that will allow a url to be used to redirect the post (i have reasons for doing it this way). I am trying to trigger this on the action “the_post”, but for some reason it doesnt seem to fire. […]

Remove action within a class in a parent theme from the child theme

I want to add some code to my child theme to remove an action set in the parent theme. The action is: add_action( ‘woocommerce_product_options_inventory_product_data’, array( ‘Electro_WC_Helper’, ‘product_options_inventory_product_data’ ) ); It is within a class ‘Electro_WC_Helper’. I have tried: remove_action( ‘woocommerce_product_options_inventory_product_data’, array( ‘Electro_WC_Helper’, ‘product_options_inventory_product_data’ ), 99 ); Which didn’t work, so I thought this is probably […]

Hook after image is uploaded and image sizes generated

I’d like to compress images once they’re uploaded to media library. Is there any hook that fires once the image is uploaded and the image sizes generated?

wordpress is_front_page() issue

I am updating the page title of all pages with a function i have created: function wpss_show_custom_description() { $wpss_disable = get_post_meta(get_the_id(), ‘wpss_disable’, true); $wpss_description = get_post_meta(get_the_id(), ‘wpss_description’, true); $wpss_description_auto = get_post_meta(get_the_id(), ‘wpss_description_auto’, true); if(wpss_check_post_type(get_post_type()) == 1 && $wpss_disable != 1){ if($wpss_description){ echo ‘<meta name=”description” content=”‘.$wpss_description.'” />’; } else { echo ‘<meta name=”description” content=”‘.$wpss_description_auto.'” />’; } […]