how to save selection meta data in user profile on frontend

Ahh it turns out it wasn’t able to stay selected because I was using the “strtolower” function to remove capital letters. Which in turn caused there to be a mismatch between the selected value and the saved value in the database. add_action( ‘show_user_profile’, ‘product_selection_field’, 3 ); add_action( ‘edit_user_profile’, ‘product_selection_field’, 3 ); function product_selection_field( $user ) … Read more

How do i use this jquery script on a wordpress site?

Its pretty simple. First you have to add a function in your themes funcition.php file to register and enqueue your scripts in head using wp_enqueue_scripts hook. // Register and enqueue all scripts in head function custom_scripts() { wp_register_script( ‘script_googleapis’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js’, false, false, false ); wp_enqueue_script( ‘script_googleapis’ ); wp_register_script( ‘script_listjs’, ‘http://listjs.com/no-cdn/list.js’, false, false, false ); wp_enqueue_script( … Read more

Order posts randomly, not by date

$randomPosts = get_posts(array( ‘orderby’ => ‘rand’, ‘posts_per_page’ => 5, ‘tag’ => $tag, )); Take a gander at the WP_Query documentation. get_posts uses WP_Query under the hood, so you can use any arguments that may be used there.

Shortcode API: How to get name that matched shortcode RegEx?

I think you just forgot to run the shortcodes [foo a=”b”] and [bar a=”c”] through the do_shortcode filter: do_shortcode( ‘[foo a=”b”] [bar a=”c”]’ ) The output of the_content() is filtered through the do_shortcode, so you can just add it into your editor instead. Running your code I get the following output for the $arguments dump: … Read more

Problem adding class to body_class

You are using array_push() incorrectly. Do this: $classes[] = ‘new-class’; Or this: array_push( $classes, ‘new-class’ ); But not: $classes[] = array_push( $classes, ‘new-class’ );

How to Display a Single Post Excerpt

the_excerpt() is one of a few template tags that do not accept a post ID as a parameter. Instead, you need to set up the global $post, run your tags, then restore it: if ( $_post = get_post( 10 ) ) { setup_postdata( $post = $_post ); the_excerpt(); // Any other template tags for this … Read more

Get all user meta by meta key instead of ID

Two options. The first will keep you away from custom SQL, and should be a lot more efficient than what you currently have. It runs two queries, one to get the user ID with the highest hourly rate, and then again to get the lowest. You need one more query to update the user meta … Read more

WordPress vs. Custom PHP [closed]

1) That depends on who is building the custom PHP site and how much effort they put into it. If you build a shoddy custom PHP site, then it can easily be hacked. On the other hand, if you don’t take certain precautions then your WP site can be hacked too. I just finished up … Read more