How to add custom fields to my custom registration form

There’s wp_login_form() for such cases. It offers tons of hooks to extend it. // In your template wp_login_form( array( /* Args: refer to Codex page */ ) ); A more in-depth look at the filters, can be found here @GitHub WP Core source. ‘login_form_top’ – above login-username ‘login_form_middle’ – above login-submit ‘login_form_bottom’ – below login-submit … Read more

Getting first Image from post

Chris’s article looks for the img tag on your post. Since you are using WordPress, and I’m assuming the WordPress uploads feature, here is how you can get the first uploaded image on your post. Paste the following code in your theme’s functions.php file. //function to call first uploaded image in functions file function main_image() … Read more

when I fetch data from remote mysql database in wordpress built in wordpress function is not working?

The WordPress APIs rely on the global $wpdb object, you can define any arbitrary object of type wpdb but that doesn’t mean WordPress will use it. Instead, something akin to the following might be better: global $wpdb; $tempDB = $wpdb; $wpdb = new wpdb(DB_USER2, DB_PASSWORD2, DB_NAME2, DB_HOST2); // do your remote SQL stuff // perhaps … Read more

Set WordPress Default Template

The better, cleaner solution would be not to use custom page templates to define page layouts*, but rather to use custom post meta to define page layouts. To implement: Create a Theme Option for Default static page layout, that includes all possible page layout options Create a _page_layout custom post meta for Page Layout, that … Read more

Can I change header.php of current theme through a plugin function?

If you are looking to insert code into the <head></head> block, then this hook does it: add_action( ‘wp_head’, ‘wpse_73900_wp_head’ ); function wpse_73900_wp_head() { ?> <!– Custom Html —> <?php } If that’s not the case, then it’s more difficult. I think it would depend on the theme providing a hook at your desired point of … Read more

Prevent Data Resubmission On Page refresh

To prevent multiple button clicks, you can use JavaScript to disable the button. jQuery(‘#review_member_button’).on(‘click’, function(evt) { jQuery(this).attr(‘disabled’, ‘disabled’); }); On the WordPress end, you can set a unique key for the form every time it’s generated and check to see if a form with that key has been resubmitted. I would recommend setting a transient, … Read more

Stop turning small dashes into longer ones

&#45; is a hyphen or minus, not a dash. Converting it to an en dash is actually the correct thing to do from a typographical standpoint. http://en.wikipedia.org/wiki/Hyphen-minus Typography is one of those deep-read kind of ideas, but the bottom line is that you think the hyphen minus is the correct character to use because of … Read more

Choose To Display Post Views With An Options Panel

So this goes in your themes functions.php file. This adds a metabox on the right side of your editscreen within posts called “Enable Post Views on this Post”: // Hook into WordPress add_action( ‘admin_init’, ‘add_custom_metabox’ ); add_action( ‘save_post’, ‘wpse_16722_save_post_views_value’ ); /** * Add meta box */ function add_custom_metabox() { add_meta_box( ‘enable_post_views’, __( ‘Enable Post Views … Read more