Only show div on homepage/blog index in wordpress/php
See: http://codex.wordpress.org/Function_Reference/is_home <?php if(is_home()): ?> <div>Your div.</div> <?php endif; ?>
See: http://codex.wordpress.org/Function_Reference/is_home <?php if(is_home()): ?> <div>Your div.</div> <?php endif; ?>
You’ll also have to fill the variable, e.g. function userinfo_global() { global $users_info; $users_info = wp_get_current_user(); } add_action( ‘init’, ‘userinfo_global’ ); And you should then be able to use $users_info everywhere in global context. Keep in mind that some template pars (header.php, footer.php, those used via get_template_part) are not in global scope by default, so … Read more
Best solution for what you want to accomplish which is essentially to make the next page feature more user friendly for your authors is to add a TinyMCE button that will do this for you. This may be a bit complicated so hold your hat. To avoid this answer being the length of a thesis, … Read more
Use do_shortcode(). For example, in a template, if you were wanting to display products specifically by ID: <?php echo do_shortcode(‘[products ids=”1, 2, 3, 4, 5″]’); ?> WooCommerce comes with several shortcodes which can be used to insert content inside posts and pages: http://docs.woothemes.com/document/woocommerce-shortcodes/ You can add shortcodes to a post or page easily via the … Read more
It’s always advised to use $wpdb->prepare when you are taking input from user. This will help in protecting queries against SQL Injection. For more details, check the Codex When you use $wpdb->prepare, you must pass the variables to the query. In your case, you can skip using $wpdb->prepare as you are using a hard coded … Read more
If you look at the source code for the_author_meta(), it simply, in essence, just echo’s the result from get_the_author_meta(). WordPress has quite a lot of functions where functions with a the_* prefix simply echos the results from its get_* counter parts. The get_* prefix is almost always used for functions which return its results. There … Read more
With get_terms(), the exclude parameter takes an array of term IDs, so just add the second term to the array: $terms = get_terms( TribeEvents::TAXONOMY, array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘exclude’ => array( 77, 71 ), ) ); echo ‘<li>Category:</li>’; foreach ( $terms as $term ) { echo ‘<li><a href=”‘.$url.’?tribe_eventcategory=’.$term->term_taxonomy_id.'”>’.$term->name.'</a></li>’; }
The documentation on wc_get_orders and WC_Order_Query is poor… Now regarding the order status in a WC_Order_Query, you can pass an array of order statuses: // Display “completed” orders count $statuses = [‘completed’]; $orders = wc_get_orders( [‘limit’ => -1, ‘status’ => $statuses] ); echo ‘<p>’ . sprintf( __(‘Count of “%s” orders: %s’), implode(‘”, “‘, $statuses), count($orders) … Read more
If you only need the title you can request it outside the loop easily. Try and call the_title() in your header. It should work But you have to be aware that if you don’t put a condition, each page of your website will display its title in the header section. EDIT: the function to call … Read more
The way I’ve done this was to take a copy of content-product.php and paste it into the root of your theme folder. Comment out do_action( ‘woocommerce_before_shop_loop_item_title’ ); and do_action( ‘woocommerce_after_shop_loop_item’ ); Quick and dirty, but it worked for me.