How to store meta field values
If you want to use the values to sort or filter the data, you should keep them as separate entries.
If you want to use the values to sort or filter the data, you should keep them as separate entries.
Found the last bit. It was just a syntax error: <?php selected( $selected, “.$term_id”. ); ?> Should be… <?php selected( $selected, $term_id ); ?> Entire Function: function tf_book_deets_create(){ add_meta_box(‘tf_book_purchase’, ‘Book Purchase Links’, ‘tf_book_purchase’, ‘books’,’side’,’default’); } function tf_book_purchase (){ global $post; $custom = get_post_custom($post->ID); $link = $custom[“link”][0]; $selected = isset( $custom[‘link’] ) ? esc_attr( $custom[‘link’][0] ) … Read more
I’m half asleep here so correct me if I am wrong here but it looks to me like you are saving the publish date of the post each time you save the post, $wr_event_end_date = isset($_POST[‘wr_event_end_date’]) ? $_POST[‘wr_event_end_date’] : ”; $event_end_date = new DateTime($wr_event_end_date); update_post_meta($post->ID, “event_end_date”, $event_end_date->getTimestamp()); This -> $event_end_date->getTimestamp() being the culprit. So regardless … Read more
This was not WPAlchemy problem. It was a matter of running a custom query. Some vital information about current post, like ID of the post I was editing got lost.
If you’re using add_meta_box, the 4th paramater should be what you’re looking for. add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args ); Use http://codex.wordpress.org/Function_Reference/add_meta_box as a reference
Change, echo ‘<input type=”checkbox” id=”movie_abc” name=”movie_abc” value=”true” />’; to… echo ‘<input type=”checkbox” id=”movie_abc” name=”movie_abc” value=”1″‘ . checked( $mydata , 1 ) . ‘/>’; …and let us know how you go. Update Try the following, echo ‘<input type=”checkbox” id=”movie_abc” name=”movie_abc” value=”1″‘, $mydata ? ‘ checked=”checked”‘ : ”, ‘/>’; Update 2 This is a duplicate question; I … Read more
You’re looking for post__in & post__not_in parameters http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters Both of them are an array of ID’s for the post’s to include or exclude in the results BTW in your code, you had a semicolon just after your foreach
The custom post type is being register as name, not snippet as is being called in add_meta_boxes action. This is because a PHP var is passed inside single quotes and it is not being interpreted. Change this: register_post_type(‘$name’, $args); To: register_post_type($name, $args); This also work: register_post_type(“$name”, $args); But never pass PHP variables inside single quotes … Read more
There are a couple filters for that. I wrote a tutorial about adding custom columns, which is where the code below is from. The example is adding a column to the ‘page’ post type that displays the page’s template. You can hook into load-edit.php and use get_current_screen to grab the correct screen ID’s/filters. From there … Read more
You’re setting $id = $post->ID; outside of the loop for agent_type posts, it’ll never match. Anyway, if you’re not doing anything with the agent_type posts that don’t match, just query for the one post you want by its ID: $list_agent = get_post_meta( $post->ID,’ec_agents’,true ); $args = array( ‘post_type’ => ‘agent_type’, ‘p’ => $list_agent ); $agent_query … Read more