Search Replace Database ONLY for posts of certain category?
Search Replace Database ONLY for posts of certain category?
Search Replace Database ONLY for posts of certain category?
To wrap the thumbnail wit I would do something like this: First. Create the expire class string $expire_class = in_category(‘expired’) ? ‘expire’ : ”; Then, wrap your post thumbnail code with this: <div class=”<?php echo $expire_class; ?>” > [put your thumbnail code here] </div> So, it looks like this: <?php $expire_class = in_category(‘expired’) ? ‘expire’ … Read more
This is quite an undertaking and difficult to answer thoroughly but this should help you on your way. I would definitely stick with variations because it makes sense from a site structure and management point of view. By default, WooCommerce will show information relevant to the option selected i.e. images, dimensions, description etc. That means … Read more
Print categories and most viewed articles
You can use get_term() to get the full term objects which contain the name. If you do this in array_map() you can convert the IDs in the array to the name: $lob = $values[data]->tag_ids; $names = array_map( function( $term_id ) { $term = get_term( $term_id ); return $term->name; }, $lob );
Just enter “https://wordpress.stackexchange.com/” OR ‘.’ (without quotes) as the value for Category base. Seemed to work perfectly when I tested it. I’d be interested in hearing if anyone discovers other dangers to doing this, other than the obvious potential of collisions between posts, pages, and categories.
worked it out already. <?php wp_list_categories(“child_of=&depth=1&hide_empty=0&title_li=”); ?> put the above code at the proper place in the files category.php or archive.php and modify “depth=0” to “depth=1”. It works. Thank you all.
category_name expects a category slug, albeit the name of the parameter. get_the_category should be used either with an ID or inside the loop – it returns the categories for the given/current post. But even if that worked, you’ll get an array of WP_Term objects – cat_name is not a property. User ->name to get the … Read more
That’s certainly possible. Use WP_Query to search for posts, then output them as you please. For example, to get 20 posts from the category with the id 4: <?php $query = new WP_Query( array( ‘category__in’ => 4 ‘posts_per_page’ => 20 ) ); if ( $query->have_posts() ) { echo “Here are some posts from that category:”; … Read more
$category_slug_array = array(‘slug_1’, ‘slug_2’, ‘slug_2’); //array of category slugs foreach($category_slug_array as $category_slug){ $my_categories[] = get_term_by( ‘slug’, $category_slug, ‘category’); //getting category object by slug } print_r($my_categories); //printing array of categories