Ajax wordpress function showing source code in alert and not value of input field?

Move the AJAX handler function hook outside of init callback and hook your script registrations to wp_enqueue_scripts. And, the hook to attach the handler callback would be wp_ajax_nopriv_postcode_ajax2. function ajax_postcode_form_init() { wp_register_script(‘ajax-login-script’, get_bloginfo(‘stylesheet_directory’). ‘/ajax-postcode-script.js’, array(‘jquery’) ); wp_localize_script( ‘ajax-login-script’, ‘ajax_login_object’, array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ), )); wp_enqueue_script(‘ajax-login-script’); } add_action(‘wp_enqueue_scripts’, ‘ajax_postcode_form_init’); function postcode_ajax2() { $postcode = … Read more

Creating wordpress user registration form

You are sending the data from the form directly to TestForm.php file, which is a PHP script outside of WordPress logic. It is and independent script. You could set the form’s action attribute to a empty string, this way the form data is sent to same page that contains the form, which is part of … Read more

Get the total Author Favorited posts

<?php $args22 = array( ‘post_type’ => array (‘menus’, ‘recipes’ ), ‘author’ => get_queried_object_id(), ‘meta_query’ => array( ‘meta_key’ => ‘simplefavorites_count’, ‘value’ => ‘0’, ‘compare’ => ‘>=’, ), ); $my_query = new WP_Query( $args22 ); echo ‘Found posts: ‘ . $my_query->found_posts . ‘<br />’; // declare variable and set total votes to 0 $total_fav_count = 0; if … Read more

Right way to display the_author_meta fields?

I would actually load them into an array: $author_contact = array( ’email’ => get_the_author_meta( ’email’ ), ‘telephone’ => get_the_author_meta( ‘telephone’ ), ‘twitter’ => get_the_author_meta( ‘twitter’ ), ); Once you have that created, you can iterate through it using a foreach() loop: <ul class=”author-contact”> <?php foreach( $author_contact as $contact => $address ) { if( isset( $contact … Read more

Custom content using in_category

in_category() accepts an array of categories to check against. So if you can get a list of all child categories for the parent category you want to check you can use that to see if your post is in any of those. You can do this by using get_categories() and specifying the parent. This will … Read more

remove_action() not working in page template – Genesis

Page templates are called too late to effect actions. You can achieve what you need another way, by targeting this in your functions, with a test for the page template, like this: function twl_content_wrap_start() { if ( !is_page_template( “page_full-width.php” ) ) return ‘<div class=”container”>’; } BTW, as a rule of thumb, actions generally don’t echo, … Read more