• Resolved bobquznie

    (@bobquznie)


    I have a few different category pages and when I load them, the title shows up as the same as the name of the latest post in that category. I need titles to show up on pages but category names to show up on all category pages. Here is a sample of the code:

    <?php if(!is_front_page()):?>
    			<div id="main">
    				<section class="main-holder">
    				<?php if(is_home()):?>
    					<header class="heading">
    						<h1><?php _e('The RICS Blog','ricssoftware');?></h1>
    						<p><?php _e('The latest news & articles from RICS Software','ricssoftware');?></p>
    					</header>
    				<?php else:?>
    					<header class="heading">
    						<h1><?php the_title();?></h1>
    					<?php if ( get_post_meta(get_the_ID(), 'page_descript', true) ) : ?>
    						<p><?php echo get_post_meta(get_the_ID(), 'page_descript', true) ?></p>
    					<?php endif;?>
    					</header>
    				<?php endif;?>
    		<?php endif;?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this:

    <?php if(!is_front_page()):?>
                <div id="main">
                    <section class="main-holder">
                    <?php if(is_home()):?>
                        <header class="heading">
                            <h1><?php _e('The RICS Blog','ricssoftware');?></h1>
                            <p><?php _e('The latest news & articles from RICS Software','ricssoftware');?></p>
                        </header>
                    <?php elseif(is_category() || is_tag()) : ?>
                        <header class="heading">
                            <h1><?php single_cat_title(); ?></h1>
                        </header>
                    <?php else:?>
                        <header class="heading">
                            <h1><?php the_title();?></h1>
                        <?php if ( get_post_meta(get_the_ID(), 'page_descript', true) ) : ?>
                            <p><?php echo get_post_meta(get_the_ID(), 'page_descript', true) ?></p>
                        <?php endif;?>
                        </header>
                    <?php endif;?>
            <?php endif;?>

    https://codex.www.ads-software.com/Function_Reference/single_cat_title

    btw:
    consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost.

    Thread Starter bobquznie

    (@bobquznie)

    Thank you but hat didn’t work. They are custom post types. I did not know that. Any ideas?

    Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this:

    <?php if(!is_front_page()):?>
                <div id="main">
                    <section class="main-holder">
                    <?php if(is_home()):?>
                        <header class="heading">
                            <h1><?php _e('The RICS Blog','ricssoftware');?></h1>
                            <p><?php _e('The latest news & articles from RICS Software','ricssoftware');?></p>
                        </header>
                    <?php elseif(is_post_type_archive()) : ?>
                        <header class="heading">
                            <h1><?php post_type_archive_title(); ?></h1>
                        </header>
                    <?php else:?>
                        <header class="heading">
                            <h1><?php the_title();?></h1>
                        <?php if ( get_post_meta(get_the_ID(), 'page_descript', true) ) : ?>
                            <p><?php echo get_post_meta(get_the_ID(), 'page_descript', true) ?></p>
                        <?php endif;?>
                        </header>
                    <?php endif;?>
            <?php endif;?>

    https://codex.www.ads-software.com/Function_Reference/post_type_archive_title
    https://codex.www.ads-software.com/Function_Reference/is_post_type_archive

    Thread Starter bobquznie

    (@bobquznie)

    Thank you so much, keesiemeijer. That fixed it!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to show category name instead of latest post name’ is closed to new replies.