WordPress query posts by custom post type not workng

It’s a bad use of Query you may look at this post In this case use a secondary query with your own instance of WP Query. query_posts() is not recommanded here cause it overrides the main query. <?php $args = array( ‘post_type’ => ‘instrument’, ‘post_status’ => ‘publish’, ‘ignore_sticky_posts’ => 1, ); $my_query = new WP_Query( … Read more

How to retain HTML5 Attributes on Markup

It is enough to add unfiltered_html capability to Editor role. Add the following code into your current theme’s functions.php: function wpse_change_capability() { $role = get_role( ‘editor’ ); if ( ! $role->has_cap( ‘unfiltered_html’ ) ) $role->add_cap( ‘unfiltered_html’ ); } add_action( ‘init’, ‘wpse_change_capability’, 10 ); Login as the user with Editor role. Test it by editing any … Read more

Best way to sort posts with different types by distance

OK, I added distance as custom field to allow me order them using wp_query orderby method! function add_distance_as_customfield($posts){ $longDest = $_GET[‘lng’]; $latDest = $_GET[‘ltd’]; foreach ($posts as $post) { $placeLocation= get_field(‘location’,$post->ID); $longPlace =$placeLocation[‘lng’]; $latPlace = $placeLocation[‘lat’]; $distance=getDistance($latDest,$longDest,$latPlace,$longPlace); if ( ! add_post_meta($post->ID, “distance”, $distance,true ) ) { update_post_meta( $post->ID, “distance”, $distance ); } } }

after checked the checkbox in backend, dont show social link on frontend

It cannot be in post metabox, because it is site setting, not specific page. You can create submenu position for settings in your admin panel by add_submenu_page function, for example: add_action(‘admin_menu’, ‘add_my_settings_submenu_page’); function add_my_settings_submenu_page() { add_submenu_page(‘options-general.php’, ‘Page title’, ‘Menu title’, ‘manage_options’, ‘my_settings’, ‘my_settings_submenu_callback’); } Then you need to create callback for last argument where will … Read more