Should I use include or load_template for including shortcodes, plugins and so on?

load_template() is for cases where you need the following global variables in an included file: $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID If you don’t need those, or if you use global in those files anyway, it isn’t needed. locate_template() and get_template_part() are for cases when you want to allow child … Read more

WooCommerce product search titles only

This is an 9 months question, but since I had the same issue and found a solution, I came here to post it. On file wp-content/plugins/woocommerce/classes/class-wc-query.php, function pre_get_posts( $q ), WooCommerce defines at line 114: add_filter( ‘posts_where’, array( $this, ‘search_post_excerpt’ ) ); This is the point when WooCommerce mess up your query! The function search_post_excerpt … Read more

How to fix Warning: call_user_func_array()?

Not sure this will help but after dealing with the exact same error message for the last 2 days I finally figured out what was happening. It was simply a matter of attempting to call the function before the system knew it existed. In my case, I had written the function in a separate–not-publicly-accessible–directory and … Read more

Woocommerce Attributes pulling in wrong data

You are confusing get_terms() with get_the_terms() get_terms() returns an array all the terms in a taxonomy. get_the_terms() returns an array of all the terms for a particular post. global $post; $terms = get_the_terms( $post->ID, ‘pa_size’); foreach ( $terms as $term ) { echo “<li>” .$term->name. “</li>”; } You might also like get_the_term_list() which would be … Read more

Empty Date Returned on my function

Replace the_date() with the_time() and it should work fine. the_date() only displays the date for posts that are on different days. If two posts are published on the same day, only the first one’s date will be displayed.

example of build_query function?

build_query() converts an array into a string to be used in an URL. You can pass an array or an object: $test1 = array ( ‘foo’ => ‘bar’, ‘hello’ => ‘world’ ); $query1 = build_query( $test1 ); print “<pre>$query1</pre>”; // foo=bar&hello=world $test2 = array ( ‘foo’ => ‘bar’, ‘hello’ => ‘world’, ‘one’ => array( 1, … Read more

right_now_content_table_end function not working?

The new action is dashboard_glance_items. It is a filter providing an array to which you can add items. Example from my plugin T5 Taxonomy Location add_filter( ‘dashboard_glance_items’, array ( $this, ‘add_to_glance’ ) ); /** * Add locations to the new “At a glance” dashboard widget. * * @param array $items * @return array */ public … Read more