Automatically Populate Post Taxonomy Data Based on Post Author Meta Data?

Figured it out for anyone who wants to know: function update_school( $post_id ) { $post_author_id = get_post_field( ‘post_author’, $post_id ); // get the post author ID $school_name = get_the_author_meta( ‘school2’, $post_author_id ); // from the post author ID, get the author meta $term = term_exists( $school_name, ‘school’); wp_set_post_terms( $post_id, $term, ‘school’ ); } // run …

Read more

Children Shortcodes?

This is possible, but you can only nest one level down, after that the shortcode regexp parser flips out. So your example would be okay, but [item1] would not be able to contain even more nested shortcodes. To enable nesting, just go ahead and do: add_shortcode(‘data’, function($attributes, $content=””) { return do_shortcode($content); } Relevant article: http://www.sitepoint.com/wordpress-nested-shortcodes/

Get the author registration date in the header.php file

If you are using this on author pages or in loop then you can simply use this. echo the_author_meta( ‘user_registered’ ); This will output registration date of author. So your function will become. if ( is_author() ) { $curauth = ( isset($_GET[‘author_name’]) ) ? get_user_by( ‘slug’, $author_name ) : get_userdata( intval($author) ); $date = the_author_meta( …

Read more

upgrade v. 2.8.5 to latest version of wordpress

Visit http://your-domain.com/wp-admin/update-core.php and look for the heading “An updated version of WordPress is available.” Below that there should a button for “Update Now”. You can update by hitting that button. If it’s not there then you will have to manually update your website. For that instructions are here. https://codex.wordpress.org/Updating_WordPress#Manual_Update

Need to hide an element depending on date and post category

Drop this into the file that is displaying the date (assuming you are using get_the_date): $month = date( ‘F’ ); $categoryIds = array(); $bannedMonth=”September”; $bannedCategory = 13; $categoryArray = get_the_category(); foreach ( $categoryArray as $categoryObj ) { array_push( $categoryIds, $categoryObj->term_id ); } if ( $month != $bannedMonth && !in_array( $bannedCategory, $categoryIds ) ) { echo …

Read more

Save selectlist value (taxonomy) in wp:wp_set_object_terms

solved it so: $part_brand = get_terms(‘brands’, ‘hide_empty=0′); <label for=”part_brand”>Бренд</label> <select name=”part_brand” id=’part_brand’> <option value=”” <?php **$brand_names = wp_get_object_terms($post->ID, ‘brands’);** if (!count($brand_names)) echo “selected”; ?>>None</option> <?php foreach($part_brand as $brand) { if (!is_wp_error($brand_names) && !empty($brand_names) && !strcmp($brand->slug, $brand_names[0]->slug)) echo “<option value=”” . $brand->slug . “” selected>” . $brand->name . “</option>\n”; else echo “<option value=”” . $brand->slug . …

Read more