Custom post type with tags

Yes, both assignments do the same, but the post_tag archive is using the post type post only by default. Don’t worry, there is a hook for you: pre_get_posts. Example with tags for pages: // register tags for pages add_action( ‘wp_loaded’, ‘wpse_75297_register_tags_for_pages’ ); function wpse_75297_register_tags_for_pages() { register_taxonomy_for_object_type( ‘post_tag’, ‘page’ ); } // add post type ‘page’ … Read more

Custom Taxonomy returns no posts

Finally I’ve figured it out, I didn’t elaborate on this in my question but I had exclude_from_search set to true on register_post_type which is obviously why no posts were being displayed in the taxonomy-video_category.php template file. Changed it to false and posts are now displayed. // … $args = array( ‘labels’ => $labels, ‘description’ => … Read more

Custom post metadata not appearing in public API

Try using the rest_api_allowed_public_metadata filter to whitelist the facebook custom field. It will then appear in the response: add_filter( ‘rest_api_allowed_public_metadata’, ‘jeherve_allow_fb_metadata’ ); function jeherve_allow_fb_metadata() { // only run for REST API requests if ( ! defined( ‘REST_API_REQUEST’ ) || ! REST_API_REQUEST ) return $allowed_meta_keys; $allowed_meta_keys[] = ‘facebook’; return $allowed_meta_keys; }

Uploaded image not appearing in custom post type

How About you try this code for your attachment $uploaded_file = wp_handle_upload( $file, $upload_overrides ); $attachment = array( ‘post_mime_type’ => $uploaded_file[‘type’], ‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, basename( $uploaded_file[‘file’] ) ), ‘post_content’ => ”, ‘post_author’ => ”, ‘post_status’ => ‘inherit’, ‘post_type’ => ‘attachment’, ‘post_parent’ => $new_reseller_id, ‘guid’ => $uploaded_file[‘file’] ); $attachment_id = wp_insert_attachment( $attachment, $uploaded_file[‘file’] ); $attach_data … Read more

How to localize value of posts

Try: function register_and_enqueue_script() { if(‘myPostType’ == get_post_type() && have_posts()) { wp_register_script( ‘js_script’, plugin_dir_url(__FILE__).’js/script.js’, array(), ‘1.8.5’ ); wp_enqueue_script(‘js_script’); $myCustomValue = array(); while(have_posts()) { the_post(); $mypostid = get_the_ID(); $myCustomValue[”.$mypostid] = nl2br(get_post_meta($mypostid, ‘custom_value’, true)); } // end while rewind_posts(); wp_localize_script(‘js_script’, ‘myCustomValue’, $myCustomValue); } // end if }