Tag Info

New answers tagged

2

No they don't change, but you shouldn't rely on them for external sites. If we're talking about purely in the database on an individual WordPress site, then: If it's a published/established post/page then yes, the ID will not change other than to delete it If its a revision, a draft, etc the ID won't change, but it won't survive for very long either. It ...


2

When a post is saved, all the data is saved in the database, and a unique ID is assigned to that specific post. All information and attachments for that post is also linked to the post's unique ID. This ID will never change, this post will forever have this ID. The post keeps this ID until the post is PERMANENTLY deleted


0

I had the same issue here when trying to make a widget that displayed featured posts with author information. I used some of the hint's from @chrisguitarguy 2nd tip. My code looked like this: <?php $count = 0; $query_args = array( 'posts_per_page' => 5, ); $com_query = new WP_Query( $query_args ); $feat_posts = $com_query->posts; ...


2

If you hook your localize script function to wp_enqueue_scripts, then you will have access to the global $post variable. As long as you pick a hook at or after 'wp' you should have access to the global $post. <?php add_action('wp_enqueue_scripts', 'YOUR_NAME_scripts'); function YOUR_NAME_scripts() { wp_enqueue_script('YOUR_NAME-js'); ...


1

At some point in the process you could do the following: Generate attachment ID from URL, like here Save attachment ID to custom field value using add_post_meta() Retrieve attachment using custom field value later with get_post_meta()



Top 50 recent answers are included