Give a unique ID while saving

When you add a meta box, the post object is passed to the function that outputs your meta box content, and the ID is immediately available. Here’s a quick proof-of-concept that will put the ID in a field in a post meta box when creating a new post: function wpd_sku_meta_box() { add_meta_box( ‘wpd_sku’, ‘SKU’, ‘wpd_render_meta_box’, … Read more

Are post, page and category IDs unique to each other?

There are multiple types of data objects: posts: pages, regular posts, nav menu items, attachments and custom post types terms for different taxonomies: categories, tags, nav menus comments links options various meta data Term ids are for a different type of objects than post ids. Both are primary keys for different tables. From Potential roadmap … Read more

Accessing Post ID Within Loop

The problem probably comes from whenever a $post has no terms set. You need to set $brand = array() outside your IF statement, add it just under get_the_terms(). At that point it also wouldn’t hurt to wrap your switch statement in a if( ! empty( $brand ) ) { Another problem I see with this … Read more

Output Post ID for all nav_items

html mark up for navigation will look like this <ul id=”menu-res” class=”main-menu”><li id=”menu-item-72″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-72″><a href=”#home”>Home</a></li> <li id=”menu-item-238″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-238″><a href=”#services”>Services</a></li> <li id=”menu-item-73″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-73″><a href=”#about”>About</a></li> <li id=”menu-item-75″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-75″><a href=”#skills”>Skills</a></li> <li id=”menu-item-346″ class=”menu-item menu-item-type-post_type menu-item-object-page menu-item-346″><a href=”http://www.yourstorepick.com/pro-site/”>Pro Site</a></li> <li id=”menu-item-347″ class=”menu-item menu-item-type-custom menu-item-object-custom menu-item-347″><a href=”http://www.yourstorepick.com/wp-signup.php?pro-site=1″>Sign up</a></li> … Read more

WP_Query custom field pass the post id

1st query: $exclude_post_top_stories=””; // WP_Query arguments $args = array ( ‘post_status’ => array( ‘publish’ ), ‘posts_per_page’ => ‘-1’, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ); // The Query $exclude_query = new WP_Query( $args ); // The Loop if ( $exclude_query->have_posts() ) { while ( $exclude_query->have_posts() ) { $exclude_query->the_post(); // do something $exclude_post_top_stories[] = get_the_id(); } … Read more