Creating a theme option page?

An example code for an options-page for a theme. Copy this code in the functions.php of the theme. if ( !function_exists(‘localizing_theme_setup’) ) { function localizing_theme_setup() { localizing_constants(); // Make theme available for translation // Translations can be filed in the /languages/ directory load_theme_textdomain( FB_LT_TEXTDOMAIN, TEMPLATEPATH . ‘/languages’ ); // instance class $localizing_theme_options = new localizing_theme_options(); … Read more

How to get posts by content?

You have to extend the db query to search in the post_content column. There is a filter: ‘posts_where’ you can use. I would write a simple wrapper for get_posts() to extends its arguments an run the filter once. Example: class T5_Posts_By_Content { protected static $content=””; protected static $like = TRUE; /** * Mapper for get_posts() … Read more

How to extend Media Library (WP 4.4)

It’s not a tab but you might be able to get started with an upload button. Check out pre-upload-ui and some actions that follow. Namely pre-plupload-upload-ui and post-upload-ui. This will add a couple buttons to the ‘Upload Files‘ tab and to ‘Media > Add New‘. BUTTONS add_action( ‘pre-plupload-upload-ui’, ‘wpse_20160202_pre_plupload_upload_ui’ ); add_action( ‘post-upload-ui’, ‘wpse_20160202_post_upload_ui’ ); function … Read more

publish_post hook isn’t working for scheduled posts

I reworked (added another version of) my function to remove the if statement to check post status, as the post is scheduled to publish it turns out i don’t need to check it again. /* the function */ function tcr_tweet2($postID) { /* get the post that’s being published */ $post = get_post($postID); $post_title = $post->post_title; … Read more

Override CSS settings of plugins

Will be interesting know which answer developers think is ‘better’, so as an alternative to Johanne’s answer (which can present difficulties if the plug-in loads scripts late, or starts moving them around without warning) Prevent the stylesheet from loading If you’ve included all necessary styling in your style.css then you can prevent the plug-in’s stylesheet … Read more

How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]

You can do what you want by hooking into the woocommerce_single_product_summary action. The action is executed inside content-single-product.php like this: <?php /** * woocommerce_single_product_summary hook * * @hooked woocommerce_template_single_title – 5 * @hooked woocommerce_template_single_price – 10 * @hooked woocommerce_template_single_excerpt – 20 * @hooked woocommerce_template_single_add_to_cart – 30 * @hooked woocommerce_template_single_meta – 40 * @hooked woocommerce_template_single_sharing – … Read more

How to add users roles dropdown in registration in wordpress

https://codex.wordpress.org/Customizing_the_Registration_Form https://codex.wordpress.org/Function_Reference/wp_update_user Instead of update_user_meta function in user_register hook use wp_update_user Following is the working example: //1. Add a new form element… add_action( ‘register_form’, ‘myplugin_register_form’ ); function myplugin_register_form() { global $wp_roles; echo ‘<select name=”role” class=”input”>’; foreach ( $wp_roles->roles as $key=>$value ) { // Exclude default roles such as administrator etc. Add your own if ( … Read more