Here is a bad way that works.
<h2 class="single_category"><?
if ($cat[0]->name != "Front_Page") {
echo $cat[0]->name;
} else {
echo $cat[1]->name;
}
?></h2>
Here is a bad way that works and takes up less space.
<?php echo ($cat[0]->name != "Front_Page") ? $cat[0]->name : $cat[1]->name; ?>
Related Posts:
- How to add “Read More…” link in twentytwenty
- Redirect to another page using contact form 7? [closed]
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- How to show related post with category DESC (ASC) IDs of ID current post
- Modifying posts based on category in TwentyTwentyTwo theme
- Custom Loop through category menu to include sub categories
- Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]
- Adding Pagination on a Custom Author Page
- How to exclude specific category from the get_the_category(); array
- Exclude custom taxonomy tag from loop
- in_category() works in single.php but not in page.php?
- Weird problem happening with custom taxonmy when creating/updating posts
- Custom category code not showing all posts
- Displaying theme options in css
- Show posts on a page based on a category and tag(s)
- Query posts by category AND custom field, then ORDERBY another custom field – help!
- WP Northwind for Theme Development?
- Add more then one site logo – custom-logo theme support
- Setting custom search engine indexing for a “dynamic WordPress page” with htaccess
- How can I defer these JS files?
- Loop through custom fields with similar label / common chars in label
- Customizer: Output default value in Customizer CSS
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Displaying recent post excerpts on static front page
- Changing layout with wp_customise
- Converting HTML Template to WordPress Theme
- Apply different Class for each element in a foreach()
- Display post category in foreach loop with category link
- Second level subcategory
- Filter Select results based on selection
- Pagination Issues using WP_Paginate Plugin
- Fastest way to get the comment and ping total count for a post
- Author Tracking Code!
- want to create a subcategory.php to manage subcats
- how to get the categories for a single product in a hierarchical way
- Exclude category from
- Automatically check parents (in a taxonomy) when child is selected
- How to create left and right menu with logo center in a custom theme?
- CPT Loop with ACF and passing ID between Loops
- How to add custom page attributes in WordPress?
- Category selectable homepage
- How do I change the markup only of a built-in widget?
- Grab posts by multiple categories
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- How to pick the default selected value in wordpress dropdown?
- How to change the category url jusy show /category/%category_id% in wordpress?
- Customizer: active_callback and sanitize_callback incompatibility?
- How can I display a PHP foreach loop’s answers by AJAX
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Counter in loop in foreach
- Alert Bar section within WP loop is displaying even though there are no posts
- Menu jumping when calling it via PHP
- Check if loop has any categories?
- Display category name only once inside loop
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- REQUIRED: Could not find wp_link_pages. See: wp_link_pages by Theme Checker
- Woo Framework: woo_cat_featured not populating
- Blog page problems
- Inside a loop, how to change CSS class based on category name?
- How can I create a permalink with two categories, with the order based on the parent category?
- how to show only specific category for a template
- Custom Database Table and foreach
- How to custom category template based on category?
- Show the categories the current post has
- How to use multiple check-box values to work in a function and insert values in database
- Exclude current post but keep the same posts-per_page amount
- List categories of a post hierarchically?
- Exclude parent categories from the_category() within the loop
- How to setup a membership system in WordPress?
- how or where wordress collect unlogged user session
- How to create social Share Buttons Without Plugin
- Remove Custom Post Category In WordPress Slug Using .Htaccess
- woocommerce remove coupon link does not work
- Make the home page template my archive/category page template without code duplication
- Get custom text if in Category
- I need to display posts in subcategory beside posts in main category
- Show the number of the post
- Create Miltiple Category Base
- How do I edit the terms output args or array data?
- wordpress custom fields loop
- Check if current post in loop is last on current page
- update_user_meta as multiple value but with same meta key
- Bootstrap slider not working
- Precheck fields when I add a new post
- Rename a folder via HTML POST request
- Trying to customise 2011 Child Theme Background Colour
- Is it possible to edit a wordpress category with Gutenberg?
- Looping through dummy posts and showing them in the main index.php
- Create category after theme setup and modify the default one
- Hide entry-header for a specific category
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Highly stylized pages
- Lightbox not showing image caption
- WordPress core jquery version file not loaded?
- Avoid showing the same phrase in the loops
- Adding a drop-down (select tag) option under Menu Settings in WordPress Admin
- Custom Post Type has wrong label and is not found when called by a loop
- Multiple loops on same category with different design
- Custom query pagination with php parameter as arg problem