Only show category to certain user levels without plugin

If I understand you have some categories, eg: ‘reserved’, ‘people’, ‘landscapes’, ‘personal’ and so on. Now you want that subscribers can see posts in, e.g. ‘people’, ‘landscapes’ categories but not posts in ‘reserved’ and ‘personal’ categories. This is relatively easy, just hook into pre_get_posts and if the request is for a post having that terms … Read more

Adding Custom User Profile data based upon Categories

here is an example //create the user category fields add_action( ‘show_user_profile’, ‘add_user_categories’ ); add_action( ‘edit_user_profile’, ‘add_user_categories’ ); function add_user_categories($user ){ ?> <table class=”form-table”> <tr> <th><label for=”user_categories”><?php _e(“User categories”); ?></label></th> <td> <?php $data = get_the_author_meta( ‘user_categories’, $user->ID ); $args = array( ‘hide_empty’ =>0, ‘taxonomy’=> ‘category’); $categories= get_categories($args); if ($categories){ foreach ( $categories as $category ){ if(in_array($category->term_id,(array)$data)) … Read more

How to only show posts on last child category

There is of course the include_children parameter for WP_Query as part of the taxonomy parameters. Which I suppose should work like this for you: $args = array( ‘tax_query’ => array( array( ‘include_children’ => false ), ), ); $query = new WP_Query( $args ); Or via parse_tax_query for your category archive: add_filter( ‘parse_tax_query’, ‘wpse163572_do_not_include_children_in_category_archive_parse_tax_query’ ); function … Read more

categories on attachment page

If you have WordPress 3.5 this will work. http://make.wordpress.org/core/2012/12/12/attachment-editing-now-with-full-post-edit-ui/ First you need to enable this in your theme, Put this in your functions.php file in your theme root. add_action(‘init’, ‘wpse_77390_enable_media_categories’ , 1); function wpse_77390_enable_media_categories() { register_taxonomy_for_object_type(‘category’, ‘attachment’); } In your image.php or attachments.php file add: $tax = get_the_term_list( $post->ID, ‘category’ ); echo $tax; Then go … Read more

Display only the latest post from multiple categories

i think you’d have to use get_posts 5 different times. what about this: global $post; $posts = array(); //categories you want to pull latest posts from; $cats = (1,2,3,4,5); foreach($cats as $cat): $args = array( ‘numberposts’ => 1, ‘category’ => $cat ); $posts[] = get_posts($args); endforeach; if($posts): ?> <ul> <?php foreach( $posts as $post ) … Read more

Redirecting specific category to subdomain

Well, thanks for hints but finally, I had to abandon the idea of subdomain due to lack of working solution for this. I made separate categories for questions and used some hooks to display&operate on them properly. Thanks to the Custom Permalinks plugin, I now have domain.com (main blog) and domain.com/forum/ (Q&A), and the latter … Read more

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