Adding Static Image to WooCommerce Content-Single-Product template

Many thanks to Nathan Powell for the fix. Changing get_stylesheet_directory() to get_stylesheet_directory_uri() will return the correct URL. get_stylesheet_directory() returns the absolute server path to child or parent theme (hence my previous issue) whereas get_stylesheet_directory_uri() returns the properly formed URI of child or parent theme. I suppose the lesson is to pay close attention to exactly … Read more

A question about register_activation hook

The register_activation_hook() is actually just a wrapper for add_action(‘activate_’ . $file, $function); and is only executed when a plugin is activated. This action/function is meant to be used by anything that should only execute once when the plugin is activated, things which would include stuff like adding custom terms to taxonomies create new database tables … Read more

Repeated Output in Widget

Your widget markup is broken! Check this line $phone_link = ‘<a class=”contact-phone” href=”https://wordpress.stackexchange.com/questions/221244/tel:%s” itemprop=”telephone”>%s</span>’; Opening tag is <a> and closing tag is </span>. Correct it with $phone_link = ‘<a class=”contact-phone” href=”https://wordpress.stackexchange.com/questions/221244/tel:%s” itemprop=”telephone”>%s</a>’;

How can I delete a wordpress widget instance?

Widgets should only be manipulated by users, and in general they should not be deleted because there is no version control for them. Therefor I suggest you rethink first before reading further. Widgets are located in two places in the DB, the sidebar_widgets option is an array of sidebars, indexed by the sidebar id. Each … Read more

Does heavy theme and plugins affect server’s response time? [closed]

You’ve touched on a few things here, and there’s both the server and the frontend response time that you’re battling with. You might have issues with both. It’s worth noting firstly that PageSpeed (and the style recalcuating alert in the Chrome timeline) both deal with front-end aspects only – in slightly different ways though (another … Read more

Add estimated value for a post according to the number of words

Here’s an idea for a starting point, by looking how the word counting is done in the /wp-admin/js/post.js file: /** * Testing word price calculations */ add_action( ‘after_wp_tiny_mce’, function() { ?><script> ( function( $ ) { $( function() { // Init var $content = $( ‘#content’ ), $count = $( ‘#wp-word-count’ ).find( ‘.word-count’ ), total_price … Read more

How to get all posts belongs to a user between a certain date

Check out the WP_Query reference. For parameters. Date Parameters. $args = array( ‘author’ => 123 , ‘date_query’ => array( array( ‘after’ => ‘January 1st, 2013’, ‘before’ => array( ‘year’ => 2013, ‘month’ => 2, ‘day’ => 28, ), ‘inclusive’ => true, ), ), ‘posts_per_page’ => -1, ); $query = new WP_Query( $args ); For the … Read more