WP Query Returning All Posts

I think you’re confusing old meta parameters with new meta_query parameters. meta_key should be just key and meta_value should be just value. Refer to WP_Query in Codex for correct syntax. Also, print_r( $country_query ); will show you the actual SQL query being sent to the database and will show you where you’re going wrong.

Save an array from drop-down in custom meta box

Quite simple. Instead of saving the post title, save the post ID, so in the front end you can extract all necessary info. Like so: get_post( $the_saved_ID_value ); or get_permalink( $the_saved_ID_value );. In you code, change this line: echo ‘<option value=”‘.get_the_ID().'” ‘.$is_selected.’>’.get_the_title().'</option>’; Notes: Using a WP_Query seems a bit too much, consider get_posts. Lots of … Read more

Shortcodes and a list of IDs?

explode will be your best option. WordPress has a few built in functions to handle arrays of function arguments (wp_parse_args and shortcode_atts for example), but nothing relating to splitting a string and iterating the result. It’s not entierly clear to me what you are trying to achieve, but let’s say you were trying to get … Read more

Admin Options page. Save as Array

You only need to register one setting and then just modify your form inputs to save the values into an array. Here’s an example of registering the setting: register_setting( ‘mytheme_settings’, ‘mytheme_settings’, ‘admin_options_sanitize’ ); $mytheme_settings = get_option( ‘mytheme_settings’ ); and the field markup: <textarea name=”mytheme_settingsAdmin Options page. Save as Array”> <?php echo esc_textarea( $mytheme_settings[‘title’] ); ?> … Read more

Pass a php string to a javascript variable

You can use the wp_localize_script to pass a variable to your javascript. Here is an example: wp_register_script(‘your_script_name’, ‘path/to/script.js’); $variables = array ( ‘footer_caption’ => $attr[‘footer_caption’], ); wp_localize_script(‘your_script_name’, ‘js_object_name’, $variables ); wp_enqueue_script(‘your_script_name’); Then you can acces to this variable by: js_object_name.footer_caption

Parsing php string in jquery [closed]

Well it seems @JacobPeattie mentioned to use json, I just echoing that. First json encode the variable $array = json_encode($out); Then send this value echo ‘<div data-ad = ‘.$array.’ class=”ash_loadmore”><span>LOAD MORE</span></div>’; To get that echo json_encode($_POST[‘ad’]) I think that’s it.BTW you don’t have now that string problem as the output will be like this {“footer-insta”:2,”sidebar-1″:3} … Read more