Articles of categories

Creating a category page by alphabet

i’m new to wordpress, and i don’t know how to code. I would like to make a page where all my animes are sorted by alphabet, like in this image I’ve heard about the wp_list_category function, so i made a separate category for each anime. Now the problem is, i dont know how to use […]

How to get the post type from a category id?

I am trying to find out the post type from a category id. Suppose that, when i am opening a category page localhost/project/foobaar/category/pen I want to know the post type to which category – pen is attached to. I have two custom post type named “book” and “copy” If category pen is associated with book, […]

Exclude category by slug for for each loop

I am trying to exclude some categories from a for-loop. <?php $categories = get_categories(array(‘exclude’ => ‘apps, windows’)); ?> <?php foreach ($categories as $category) : ?> // the_loop <?php endforeach; ?> Even though no error is thrown, it doesn’t work: all categories are used in the loop. How can I exclude some categories by slug? I […]

Show only one category

I have this code to show cathegory like image: <?php foreach((get_the_category()) as $cat) { $catname =$cat->category_nicename; echo “<a href=\”/category/”; echo $catname; echo “/\”>”; echo “<img src=\”/wp-content/categorias/”; echo $catname; echo “.png\” alt=\”$catname category image\” /></a>\n”; } ?> The problem is: I want to show only one category by post because I have a lot of posts […]

Include posts from feature category in pre_get_posts

I have two custom taxonomy ‘cities-taxonomy’ and ‘userfeed-taxonomy’ and I am excluding all the post which has these taxonomies assigned in my blog page using pre_get_post(); Here is my query add_action( ‘pre_get_posts’, ‘my_filter_main_query’ ); function my_filter_main_query( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $terms1 = get_terms( array( ‘userfeed-taxonomy’ ), array( ‘fields’ => […]

Display the latest post from a category in a page

I want to display in page the latest post content from a category. For example, the category foo has the following posts: Hello World Hello Mars Foo bar Considering Foo Bar the latest article from foo category, its content should be rendered in a page: <title> <content> Where <title> is Foo bar and <content> is […]

How do I edit pre_get_post for the category the user is currently in?

I’ve got a Woocommerce site that uses categories and products within those categories but how do I get my search form to only display results of products within the category the user currently is in. I’ve looked around and the closest I’ve got to is this: add_action(‘pre_get_posts’,’shop_filter_cat’); function shop_filter_cat($query) { if (!is_admin() && is_post_type_archive( ‘product’ […]

Use post as category

I created two kind of custom post type: “Fields” and “Functions”. Can I associate a post field with some function post (like if function was a category). I choose to use “Functions” as post, cause in its page there are many content (picture, video and text). “Function” works like category, but have content like a […]

How to show author name only if the post is in a specific category?

I have this function in my theme, what i want is to display author name only for the selected category (say category id 90). No author name should be displayed for the rest of the categories. I believe > in_category can do this. I also tried some function but no luck as I’m not good […]

How Can I Display Categories Description

I need to Display Categories Description. I create a new file category.php with archives.php template. i try this function but its not working. <?php echo category_description( $category_id ); ?>