• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

? If specific category → don't show the category name

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › ? If specific category → don't show the category name

This topic is: resolved

Tagged: php switch statement

  • This topic has 5 replies, 3 voices, and was last updated 7 years, 10 months ago by Matus.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • July 13, 2017 at 10:31 am #209066
    Matus
    Member

    Hello everybody,
    I have a PHP function (below), which I'm adding into functions.php file in my Genesis Sample Theme.
    This code shows the name of the category in post and in my case it's outputted in entry header.
    I already style it with CSS, but I need a little help with taking this code a step further.

    I'd like to add to this code condiction if is post filed under category named "Blog", this category won't be displayed.
    But if is the post filed except the category "Blog" also in other categories, don't show just category "Blog".
    So, my question is: How to do that?

    My code:

    add_action ('genesis_entry_header' , 'category_name_link', 11);
    function category_name_link() {
    	$categories = get_the_category();
    	if ( ! empty( $categories ) )
    		?>
    			<div class="category-custom">
    				<?php echo '<a href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>'; ?>
    			</div>
    		<?php
    }

    I'll appreciate any advice.

    July 14, 2017 at 1:54 am #209086
    Brad Dalton
    Participant

    Please clarify the conditionals?


    Tutorials for StudioPress Themes.

    July 14, 2017 at 3:50 am #209090
    Matus
    Member

    I'd like to display article category in post.
    I don't want to use the standard edit method - StudioPress plugin Simple Edits.
    What I don't like about this plugin I can choose only entry meta (above and below) article sections and there put some available shortcodes.

    My conditions:
    1. Display post category above post title. This category should be also linked to its archive page. (When I click on category named Newsletter, I will be redirect to the Newsletter category archive page.)
    2. If is article filed under category Blog, don't display just category Blog.
    3. Don't display categories in pages (that's I think sure thing because pages don't have categories).

    July 14, 2017 at 4:09 am #209093
    Matus
    Member

    One more think.
    I don't want to display text "Filed under:" before categories.
    Just the names of categories separated without comma (I'll style it so each category will have own border around itself).

    July 14, 2017 at 8:08 am #209107
    clintongallagher
    Member

    My advice is about the switch statement. It is the way we solve problems like the one you're working with. Learn it. A couple of YouTube videos and you'll have it down pat.

    July 27, 2017 at 1:57 am #209621
    Matus
    Member

    I resolved this problem. I created one category "Blog" and then every other category I set as subcategory to the Blog. In the posts I add categories I wanted except Blog. Because the Blog is the main category I was able to find all the posts in Blog page.

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble