Editing post in admin panel
Editing post in admin panel
Editing post in admin panel
you can use following way $attachment_id = 5; //put here you attachment id $sql = “SELECT count(DISTINCT pm.post_id) FROM $wpdb->postmeta pm JOIN $wpdb->posts p ON (p.ID = pm.post_id) WHERE pm.meta_key = ‘_thumbnail_id’ AND pm.meta_value=”$attachment_id” AND p.post_type=”post” AND p.post_status=”publish””; $count = $wpdb->get_var($sql);
The initial thing that jumps out is that you’re using: template=default in the URL, but in the code you are using if( isset($_GET[‘_wp_page_template’]) && !empty($_GET[‘_wp_page_template’]) ) { you should be checking: if( isset($_GET[‘template’]) && !empty($_GET[‘template’]) ) { Also, don’t forget to sanitize the $_GET as that’s user input and cannot be trusted. Hope that helps.
Getting meta content from get_next_post & get_previous_post
This part: // verify nonce if (!wp_verify_nonce($_POST[‘subtitle_meta_box_nonce’], basename(__FILE__))) { return $post_id; } else { die( ‘failed to verify nonce’ ); } should be: // verify nonce if (!wp_verify_nonce($_POST[‘subtitle_meta_box_nonce’], basename(__FILE__))) { return; }
Your options are: Paste the code into a plugin Paste the code into a mu-plugin file Paste the code into a theme file like functions.php I manage this kind of thing with a plugin that builds a simple interface– basically an “execute” button. I alter the code that executes as needed. That seems to give … Read more
Just add custom-field support to your custom post; register_post_type( ‘YourPosts’, array( ‘labels’ => array( ‘name’ => __( ‘YourPosts’ ), ‘singular_name’ => __( ‘YourPost’ ) ), ‘public’ => true, ‘has_archive’ => true, ‘supports’ => array( ‘title’, ‘editor’, ‘custom-fields’, ) ) );
title is not part of the current HTML5 spec for meta element names. See here. The <title> element in the document head should be enough for metadata purposes.
Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
Depending on the way your theme uses the_title, hooking into the the_title filter may or may not hide the title h1. What theme are you using? The the_title filter passes two arguments: the title (string) and the post ID. Therefore, treating the title as an array (it looks like you’re assuming $title is an array … Read more