How to get category names in post_class?
You have to pass the values, not echo them. So something like this should work: $post_cats = get_the_category(); $slugs = wp_list_pluck( $post_cats, ‘slug’ ); post_class( join( ‘ ‘, $slugs );
You have to pass the values, not echo them. So something like this should work: $post_cats = get_the_category(); $slugs = wp_list_pluck( $post_cats, ‘slug’ ); post_class( join( ‘ ‘, $slugs );
Hi thanks this is solved now i got help from a developer i know he fixed for me basically wp_set_object_terms() has a fourth argument called append. Setting that to true during the call should add the term without unsetting the already set terms. so thats if anyone else has this issue thanks again to all … Read more
for sub-pages of current page check wp_list_pages() <?php $page_id = get_the_ID(); wp_list_pages( array( ‘child_of’=>$page_id ) ); ?> and for sub-categories of the parent category check wp_list_categories() <?php $cat_id = get_query_var(‘cat’); if( !empty($cat_id) ) { wp_list_categories( array( ‘child_of’=> $cat_id ) ); } ?>
to solve this you can create a page template, on this page template 1.get the top level categories only, set parent value to zero $args = array( ‘orderby’ => ‘name’, ‘parent’ => 0 ); $categories = get_categories( $args ); 2.get posts in all parent categories foreach ( $categories as $category ) { $all_posts=get_post(‘category=’.$category->term_id); foreach( $myposts … Read more
Use get_the_post_thumbnail with a new WP_Query. <?php if ( has_post_thumbnail()) { $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), ‘large’); echo ‘<a href=”‘ . $large_image_url[0] . ‘” title=”‘ . the_title_attribute(‘echo=0’) . ‘” >’; echo get_the_post_thumbnail($post->ID, ‘thumbnail’, array(‘class’ => ‘aligncentre’)); echo ‘</a>’; } ?>
If the Categories referred to here are the WordPress native category taxonomy, the queries for these term pages by default will only include the native post post type. To add custom post types to category term queries, you can add a bit of code to your theme’s functions.php file, which modifies these queries via the … Read more
See Taxonomy Parameters documentation – there is include_children parameter, which you can set to false in your taxonomy query.
If your Loop is constructed correctly $post will be set for each post in the loop in turn. You could also consider using get_the_ID. get_post_meta($post->ID, “user_submit_url”, true); by itself won’t do much. You will have to format and echo the information but that should retrieve your post meta data. For example, to generate a link … Read more
Did you try BulkPress Plugin? Easily add and manage multiple categories, pages, custom taxonomy terms and custom post type posts. Create and reorder terms
You can’t use the category name to search for categories. You can use the slug. Be aware of the difference. A slug is normalized to lower case with spaces replaced by dashes. The slug for “Foo A” would be “foo-a”. Using “Foo A” will not work. $admin_cat = get_option(‘admin_cat’); if (ctype_digit(“$admin_cat”)) { // this is … Read more