Add custom taxonomies as class names to an archive page of custom post types

The function you mention is going to return a list of links — aren’t you just trying to get the term slug as a class? Why not do…. $terms = get_the_terms($post->ID, ‘my-category’); $more_terms = get_the_terms($post->ID, ‘another-category’); $slug_out = array(); foreach($terms as $term){ $slug_out[] = $term->slug; } foreach($more_terms as $term){ $slug_out[] = $term->slug; } echo ‘<div … Read more

Problem with custom menus

You have created menu “placeholders” of sorts but you haven’t added any actual menus yet, thus you see a kind of default menu being displayed. Go to wp-admin -> Appearance -> Menus Create a menu Assign the menu to one of your menu locations Add something to the menu Save Now you should see the … Read more

pre_get_posts redirecting

you can allow only registered user to see your content by 1.this solution for post show only to login user class RavsPublic { function __construct() { add_action(‘pre_get_posts’, array($this, ‘try_redirect’)); } function try_redirect( $query ) { // not on home page and not login if( !is_home() && !is_user_logged_in() ){ // send them to home page wp_redirect( … Read more

Set posts per page for parent category and it’s all children

You want get_term_children. function hbg_category_query( $query ) { if( $query->is_main_query() && $query->is_category()) { $categories = get_term_children(1,’category’); $categories[] = 1; // add your special category if (is_category($categories)) { $query->set( ‘posts_per_page’, 32 ); } } return $query; } add_action(‘pre_get_posts’,’hbg_category_query’); Barely tested, but I think that will work.