Hot answers tagged custom-field
5
A simple user meta row can handle that for you (the second issue), you can store the post id and the vote (up/down) in an array and that is just the same as post meta ex
/**
* update user vote per post
* @param int $user_id
* @param int $post_id
* @param mixed $vote can be an integer 1 / -1 and can also be a string "up"/"down"
* @return void
*/
...
2
A simple and cleaner solution would be to use !in_array ex:
function mf_1_remove_meta_boxes() {
if( !is_admin() && !isset( $_GET['post'] ) )
return;
if( !in_array($_GET['post'], array('194','185','2') ) )
remove_meta_box( 'mf_1', 'page', 'normal' );
}
this way you can just add the ids in the array and as many as you want
1
Yes, you can do this with built in functions. You've got a very broad question and a working solution would be a fair bit of work, but there a couple of ways to handle this with core functions that seem workable to me.
Store everything in post meta.
You could do this with only the two fields you are already considering. Instead of saving a counter, save an ...
1
I assume that you want to update custom field.
You can use:
global $post;
update_post_meta($post->ID, $meta_key, $meta_value);
http://codex.wordpress.org/Function_Reference/update_post_meta
1
You are getting an error because get_the_meta isn't a function. Just because many the_* functions have a corresponding get_the_* function, it doesn't mean that all do.
What you want is get_post_meta or get_post_custom. Those will return arrays which you will have to loop over and format yourself. the_meta uses get_post_custom. You can use its code as a ...
Only top voted, non community-wiki answers of a minimum length are eligible