How to remove all javascript in a theme wordpress?

You either use the admin_*/wp_print_scripts hook or the admin_*/wp_print_styles hook. The styles hook comes before the print scripts hook, so maybe it fits better than just using a priority of 0 for the *_print_scripts hook (there might be function with a name that’s hooked in earlier on priority 0). function wpse61635_remove_all_scripts() { global $wp_scripts; $leave_alone … Read more

WooCommerce change number of columns in the frontpage

You didn’t say what snippets you’ve actually tried, but according to the docs, you can filter loop_shop_columns like so: function wpa65503_woo_shop_columns( $columns ) { return 3; } add_filter( ‘loop_shop_columns’, ‘wpa65503_woo_shop_columns’ ); tested and working for me with Twenty Eleven theme. EDIT – this is the particular line in the default content-product.php template file that makes … Read more

adding meta data using plugin to top of head

Okay, here’s the answer: function CustomHead() { include(‘headcontent.php’); } add_action(‘wp_head’,’CustomHead’,1,1); The key is that first “1”, which sets the priority of it to run at the highest (this is an optional element, defaulting to 10, putting it at the end of the head by default). More info here: http://codex.wordpress.org/Function_Reference/add_action

Avoiding Duplicate function names in Post Loop (WP_Footer script)

I would wrap the whole thing in a class and put your data into a class var. class WPA69616_Plugin { private $data=””; public function __construct() { add_shortcode(‘my_shortcode’, array($this, ‘add_content’)); add_action(‘wp_footer’, array($this, ‘output_content’)); } public function add_content($atts) { extract( shortcode_atts( array( ‘content’ => ” ), $atts ) ); $this->data .= $content; } public function output_content() { … Read more

Error handling a plugin with exceptions

You can also extend expections and then catch only those that you throw. For example: function do_add_my_pws_exceptions() { class PWS_Exception extends Exception {} class PWS_Init_Exception extends PWS_Exception {} } add_action(‘plugins_loaded’, ‘do_add_my_pws_exceptions’); Of course, you should be certain the user is running at least version 5 of PHP by having your theme of plugin activation do … Read more

Can’t get title of latest post

You’re getting there! Couple of issues – you need to actually grab the latest posts before you can work on them. And post_title is not a property of the ID, but the object itself: if ( $posts = get_posts( ‘numberposts=1’ ) ) { $title = $posts[0]->post_title; // carry on sir } Note: Ensure you have … Read more

Can’t get plugin settings page to save data

While you are using Settins API, that’s why you don’t need to use update_option or add_option functions. Settings API would handle that by self. There were few issues that’s why your code is not working. 1. add_settings_section( ‘wpa_ad_insert_main’, ‘Ad Insertion Settings’, ‘wpa_ad_insert_section_text’, ‘wpa_ad_insert’ ); 3rd parameter is the callback function. Since, you don’t need this … Read more

How to Sort the Favorite Plugins Screen Alphabetically?

That page is rendered by the WP_Plugin_Install_List_Table class, which calls the function plugins_api(). In this function, we find two filter hooks that enable the manipulation of the table output: plugins_api_args and plugins_api_result. The problem is that the API doesn’t offer an ordered query, so we can only sort each page results. The solution is to … Read more