WordPress select query issue

One more for the pot: $wpdb->get_col can be used to return a “single dimensional” array of all values set for “sleeps” global $wpdb; $values = $wpdb->get_col( “SELECT meta_value FROM wp_postmeta WHERE meta_key = ‘sleeps'” ); echo implode(‘,’, array_unique($values) );

Open/closed function [closed]

I’ve sourced the CSS from https://codepen.io/vram1980/pen/Kyaie all credit above. Putting it with your function, you can do something like this: add_shortcode( ‘linestatus’, ‘line_status_handler’ ); function line_status_handler( $atts ) { extract( shortcode_atts( array( ‘open_time’ => ’09:00:00′, ‘closed_time’ => ’17:00:00′, ‘open_text’ => ‘our lines are open’, ‘closed_text’ => ‘our lines are closed’, ), $atts ) ); $opened … Read more

WordPress Admin sub-level menu issue

Got it working like this: function print_admin_menu() { add_options_page( ‘Print Configuration’, ‘Print Configuration’, ‘manage_options’, ‘print_admin_config_page’, ‘my_callback’ ); } function my_callback(){ ?> <div class=”wrap”> <h2>Welcome To My Plugin</h2> </div> <?php }

Get Posts by Custom Taxonomy on Custom Post

<?php // get the WP_Query object $query = new WP_Query($args); // Missed essential point: // loop through the WP_Query object // to get the array of distinct posts objects $coaches = $query->posts; // each $coach is distinct post object now foreach( $coaches as $coach ) { // echo $coach->ID; }

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