Giving the_excerpt in the place of the_content?

All good examples. But they weren’t working for me with the theme (pinboard) and plugin I was using (secondary-html-content) and what I wanted to do. The first challenge was to make sure that I get both pieces of content instead of just one. The second challenge was to replace the excerpt on the homepage with … Read more

How to fix my old theme so it loads jQuery properly

Taking a stab at a general answer, since we don’t (yet?) have access to the specific Theme. Note: all of these edits can – and perhaps should – be implemented via Child Theme. First, you need to remove ALL of those lines from header.php. Scripts should be enqueued, rather than hard-coded into the template. Then, … Read more

Bug: Post needs to be updated twice when adding action for save_post hook

You’re doing several things wrong, and they’re all silly, avoidable, basic logic mistakes. Firstly, you’re not checking if this is an autosave. Autosaves do not save the custom fields, only the original core wordpress fields, like content, so an autosave will giv eyou unset/blank values. Add this to the top of your save function: if … Read more

get_current_screen and the WP_Screen class

wp_enqueue_scripts is only fired on the front end, and not on admin screens. For loading scripts admin side, you’ll want the hook admin_enqueue_scripts. Passed as an optional argument is the page hook. (Examples include edit.php, for the admin edit page (which lists pages/posts/ cpt posts), post.php when editing a post/ custom post type and post-new.php … Read more

Plugin uninstall function is not working

register_deactivation_hook() is launched when a plugin is deactivated. For plugin uninstall, there is register_uninstall_hook(). WordPress plugins can also have a file called uninstall.php that is ran whenever the plugin is uninstalled. To prevent the uninstall.php file from being triggered directly, the state of a constant called WP_UNINSTALL_PLUGIN should be checked before launching the codes for … Read more

Include WooCommerce 2’s prettyphoto scripts on all site pages

Try adding this to your theme’s function.php. It worked for me, hope it helps. // PRETTY PHOTO // add_action( ‘wp_enqueue_scripts’, ‘lightbox’ ); function lightbox() { global $woocommerce; $suffix = defined( ‘SCRIPT_DEBUG’ ) && SCRIPT_DEBUG ? ” : ‘.min’; { wp_enqueue_script( ‘prettyPhoto’, $woocommerce->plugin_url() . ‘/assets/js/prettyPhoto/jquery.prettyPhoto’ . $suffix . ‘.js’, array( ‘jquery’ ), $woocommerce->version, true ); wp_enqueue_script( … Read more