• Resolved iwildeachit

    (@terryit3)


    I am trying to figure out how to display a line of text if the ‘jobs’ category has no posts.
    I have accomplished this in other themes, but I am not sure how to do this in Hueman.

    Thanks for any help

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter iwildeachit

    (@terryit3)

    Just naming the file Hueman uses to display categories would be helpful. I’ve tried editing the archive.php file and making a new category-jobs.php file in my child theme. Neither changes the category page.

    The file name category-jobs.php should be working. Is “jobs” a category or a custom post type?

    Thread Starter iwildeachit

    (@terryit3)

    jobs is the category slug. I do not use any custom post types at the moment.
    I may have to clear my cache/cookies and try again.

    If you have access to your server’s logs, do they show anything unusual? Can you temporarily turn on debugging and see if there are any error messages?

    Thread Starter iwildeachit

    (@terryit3)

    I got the category template working by clearing my browser cache, now I am having trouble putting the code together..

    In my previous website’s theme, I use

    <?php if ( is_category(jobs) ) { ?>
    <h1><?php esc_html_e(' &nbsp;No Job Openings','TheStyle'); ?></h1>
    	<p><?php esc_html_e(' &nbsp;The library has no job openings at this time. Please check back later.&nbsp;','TheStyle'); ?></p>

    but I don’t know how to achieve that with the code used in Hueman. Hopefully someone can help me integrate this. The code for Hueman is:

    <div class="post-list group">
    				<?php $i = 1; echo '<div class="post-row">'; while ( have_posts() ): the_post(); ?>
    				<?php get_template_part('content'); ?>
    				<?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
    			</div><!--/.post-list-->
    
    			<?php get_template_part('inc/pagination'); ?>
    
    		<?php endif; ?>

    You should add the code in between <?php get_template_part('inc/pagination'); ?> and <?php endif; ?> like this:

    <?php get_template_part('inc/pagination'); ?>
    <?php else : ?>
    <h1><?php esc_html_e(' &nbsp;No Job Openings','TheStyle'); ?></h1>
    <p><?php esc_html_e(' &nbsp;The library has no job openings at this time. Please check back later.&nbsp;','TheStyle'); ?></p>
    <?php endif; ?>

    Because the file is named category-jobs.php, you don’t need to check for the appropriate category: WordPress will only use this file to display the archives for the category “jobs”. If there are posts in that category, WordPress will display them as normal, but if there aren’t any posts, WordPress will display your added code instead.

    Thread Starter iwildeachit

    (@terryit3)

    Worked like a charm.
    Thank you very much!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Display text on empty category page?’ is closed to new replies.