2.4k questions

2.4k answers

98.9k users

4 Online Users
0 Member 4 Guest
Today Visits : 505
Yesterday Visits : 4682
Total Visits : 2478379

Categories

Notice

Dear All, These are my answers from Quora and primarily Google; please check the answer and from others sites; the answers are free and without any liability.To make a decision, write down all of the positives and negatives on a piece of paper.Thank you,

Elias Katsaniotis, MSc

Information

Viktoria Katsanioti,

Kaliningrad,

Russia,

matizegr@yahoo.com

0 votes
35 views

How do you use an if/else statement with the_category (categories, WordPress)?
in WordPress by (95.8k points)

1 Answer

0 votes

use is_category()   see

is_category() | Function | WordPress Developer Resources

Determines whether the query is for an existing category archive page.

https://developer.wordpress.org/reference/functions/is_category/

also see

Constructing An if Statement with is_category(); in archive.php (WordPress)

I am trying to use an if statement with is_category() in order to build a bigger piece of code later. I can't get the code to recognize the if statement though. Basically below I've posted the coding

https://stackoverflow.com/questions/11659177/constructing-an-if-statement-with-is-category-in-archive-php-wordpress

  • if(is_category()) { 
  • echo "category!"; 

    also see

    the_category if/else statement

    I need to do the following: The sense if I have a class dportfolio - show a category dportfolio. Otherwise show usual category. I use: if ( class_exists( 'DPortfolio' ) ) { echo DPortfolio::

    https://wordpress.stackexchange.com/questions/165984/the-category-if-else-statement

    I need to do the following: The sense if I have a class dportfolio - show a category dportfolio. Otherwise show usual category.

    I use:

    • if ( class_exists( 'DPortfolio' ) ) { 
    • echo DPortfolio::instance()->dportfolio_get_category(); 
    • }; ?> 
      by (95.8k points)
      ...