using wp_footer hook in a plugin

Firstly, remove the margin-left CSS property from your html and then try if it works. May be your html is being hidden behind any other html. Or better try this first – Remove the current code from your function and just write any non html thing. Then put a die() or exit() and see if … Read more

Quick press publish post hook

As Wyck said, it’s just a form that uses post.php. To check if QuickPress is the one making the call use: add_action( ‘publish_post’, ‘check_for_quickpress_wpse_109961’ ); function check_for_quickpress_wpse_109961( $post_id ) { if( ‘post-quickpress-publish’ == $_POST[‘action’] ) { // do_something(); } }

What hook to use to redirect based on $post

add_action( ‘pre_get_posts’, ‘mytheme_restrict_user_content’ ); function mytheme_restrict_user_content( $query ){ $restricted_post_types = array(‘documentlibrary’, ‘events’); if ( is_main_query() && is_singular($restricted_post_types) && ! is_user_logged_in() ) { $redirect = set_url_scheme(‘http://’ . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’]); wp_redirect( wp_login_url($redirect, true) ); exit(); } } I don’t use auth_redirect because that function check if the user is logged in, but we already know that … Read more

WooCommer Product Category Loop – How to change the display order of the rating and price?

For example you just want to swap rating and price where price would come before rating, you would do the following. remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 ); remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_rating’, 5 ); add_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 11 ); add_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_rating’, 12 ); Put these lines of code in your theme’s functions.php file.

How to hook into action/filter call

The callbacks hooked onto ‘all’ are called prior to the callbacks for any hook (action and filters) being called. (See source) add_action( ‘all’, ‘wpse115617_all_hooks’ ); function wpse115617_all_hooks(){ //This is called for every filter & action //You can get the current hook to which it belongs with: $hook = current_filter(); } See http://queryposts.com/function/current_filter/

hook for loading page

Filter the_content and check if is_page( ‘jobs’ ) is TRUE: add_filter( ‘the_content’, ‘get_scrapy_scraped’ ); function get_scrapy_scraped( $content ) { global $wpdb; if ( ! is_page( ‘jobs’ ) ) return $content; $table_name = $wpdb->prefix . “Careers”; $retrieve_data = $wpdb->get_results( “SELECT * FROM $table_name” ); if ( ! $retrieve_data ) return $content; $table=”<table><tr> <th>Job Name</th> <th>Location/Dept</th> <th>Complete … Read more

How to pass hook variable to function?

You can’t use an action or hook within a function in the way you are expecting. Actions and hooks are about delayed execution You are attaching code that will execute at a later point. After an action is added, your function will continue as normal. Then when the user is actually being registered, your code … Read more

Is there a way to change select-list for new custom taxonomy?

If someone else stumble upon this kind of question, here’s my solution to it: (without having to mangage any metaboxes etc) add_action(‘categorycourses_add_form_fields’,’categorycourses_edit_form_fields’); add_action(‘categorycourses_edit_form_fields’,’categorycourses_edit_form_fields’); //Function only showing parent categories when editing or adding new category-courses function categorycourses_edit_form_fields() { ?> <script type=”text/javascript”> jQuery(document).ready( function($) { var level = 1; //Go down in hierarchy from level1 and remove … Read more