Adding text to Category pages & Tag pages

Question: is there a way to add the functionality of text being displayed on category pages and tag pages?

I would like to have text shown above the posts on those pages. And I like to write the text in Posts > Category or Posts > Tags, in wordpress. Because it’s custom written for every page…

By the way, I’ve set up a Child theme already.

Hi There,

Please add the following code under functions.php file locates in your child theme:

add_action( 'x_before_view_global__index', 'print_custom_header' );
function print_custom_header(){
	if( is_category() || is_tag() ){
		?>
		<div id="blog_section" class="x-section" style="margin: 0px;padding: 45px 0px; background-color: transparent;">
			<div class="x-container max width" style="margin: 0px auto;padding: 0px;">
				<div class="x-column x-sm x-1-1" style="padding: 0px;">
					<p>This is your text!</p>
				</div>
			</div>
		</div>
		<?php
	}
}

Hope it helps :slight_smile:

Thanks Thai, but it is not exactly the answer I was looking for.

Every catergory page (and every tag page) has it’s own text. Currently, (with an other theme) I add unique text to each and every category page and tage page. I add this text in Wordpress (/wp-admin/term.php?taxonomy=category&tag_ID=6&post_type=post), not by editing a file in the source files.

How could I add this feature to this theme?

I think it is called: category discription (and for tage pages: tag discription). So far, it doesn’t show the text I’ve written in Wordpress.

Hello There,

Since you want to display category or tag description, you may use this modified code base from the previous one:

add_action( 'x_before_view_global__index', 'print_custom_header' );
function print_custom_header(){ ?>
	<?php if( is_category() || is_tag() ) : ?>
		<div id="blog_section" class="x-section" style="margin: 0px;padding: 45px 0px; background-color: transparent;">
			<div class="x-container max width" style="margin: 0px auto;padding: 0px;">
				<div class="x-column x-sm x-1-1" style="padding: 0px;">
					<?php if( is_category() ) : ?>
						<p><?php echo category_description(); ?></p>
					<?php endif; ?>

					<?php if( is_tag() ) : ?>
						<p><?php echo tag_description(); ?></p>
					<?php endif; ?>
				</div>
			</div>
		</div>
	<?php endif; ?>
<?php }

We would loved to know if this has work for you. Thank you.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.