Return category slug / title from category ID

get_category will return all the information you need for both cases. $catinfo = get_category(get_field(‘category_test’)); From the Codex, that will give you (sample data obviously): stdClass Object ( [term_id] => 85 [name] => Category Name [slug] => category-name [term_group] => 0 [term_taxonomy_id] => 85 [taxonomy] => category Return category slug / title from category ID => … Read more

Show posts on a Google Map

Lots of ways to proceed here. Here’s one way to do it: Find a JavaScript/jQuery plugin that works with map markers. I used Mosne Map, it’s old but it works. Generate the HTML markup that the above plugin will use. I needed a more user-friendly way to add markers, so I utilized ACF’s Repeater Field … Read more

get_post_custom single array

this is what I’ve done to achieve this, it will return single dimension array when single results are found, and bi-dimensional array when multiple results are found /* * Get post custom Single (in functions.php) */ function get_post_custom_single($post_id) { $metas = get_post_custom($post_id); foreach($metas as $key => $value) { if(sizeof($value) == 1) { $metas[$key] = $value[0]; … Read more

Automatically assign taxonomy term if custom meta value exists

You should hook onto the save_post action. add_action( ‘save_post’, ‘add_video_taxonomy’ ); function add_video_taxonomy( $post_id ) { // you should check if the current user can do this, probably against publish_posts // you should also have a nonce check here as well if( get_post_meta( $post_id, ‘video_url’, true ) ) { wp_set_post_terms( $post_id, ‘video’, ‘your_custom_taxonomy_name’, true ); … Read more

Saving an array in a single custom field

You can json_encode() it which will make it a string that you can put into a custom field then just ensure you json_decode() it to bring it back to an object or json_decode($data, true) to bring it back as an array $arr = array(“Accounting”=>”Peter”, “Finance”=>”Ben”, “Marketing”=>”Joe”); update_post_meta($post_id, “my_custom_meta_key”, json_encode($arr)); $json_data = get_post_meta($post_id, “my_custom_meta_key”, true); // … Read more

Custom field values repeating

Your foreach is the problem. You’re iterating once for each offering, yet you’re evaluating ALL offering values in the array each time. So your PHP is dutifully printing all available offerings * the number of offerings. I’d say go without the foreach() and see what happens. EDIT 1 Also please note, you’re casting strings to … Read more

template_redirect for single posts w/ custom fields

The problem with your code is that you’re checking is_single() when your plugin is first loaded, before the global query has run, so is_single() still returns false. You should move the is_single() check within your my_template function: function my_template() { if(is_single() && have_posts() && ‘Custom’ == get_post_meta(get_the_ID(), ‘Design’)) { include(PLUGINDIR . ‘/supersqueeze/all.php’); exit; } } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)