Reply To: Category name post on page

NapitWPTech Theme Support Forums Masonry Brick Category name post on page Reply To: Category name post on page

#162

Bishal Napit
Keymaster

Hi Fra79Valex,

For adding that in the meta-tags area, you might not need to do the same work as stated above. You can just add the below PHP code in the functions.php file of the child theme and check:-

function masonry_brick_posted_on() {
	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
	if (get_the_time('U') !== get_the_modified_time('U')) {
		$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
	}

	$time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date())
	);

	$posted_on = sprintf(
			esc_html_x('%s', 'post date', 'masonry-brick'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . '<i class="fa fa-calendar"></i>' . $time_string . '</a>'
	);

	$byline = sprintf(
			esc_html_x('%s', 'post author', 'masonry-brick'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . '<i class="fa fa-user"></i>' . esc_html(get_the_author()) . '</a></span>'
	);

	echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.

	if ('post' === get_post_type()) {
		/* translators: used between list items, there is a space after the comma */
		$categories_list = get_the_category_list(esc_html__(', ', 'masonry-brick'));
		if ($categories_list && masonry_brick_categorized_blog()) {
			printf('<span class="cat-links">' . wp_kses(__('<i class="fa fa-folder-open"></i>%1$s', 'masonry-brick'), array('i' => array('class' => array()))) . '</span>', $categories_list); // WPCS: XSS OK.
		}
	}

	if (!post_password_required() && ( comments_open() || get_comments_number() )) {
		echo '<span class="comments-link">';
		comments_popup_link(wp_kses(__('<i class="fa fa-comment"></i>Leave a comment', 'masonry-brick'), array('i' => array('class' => array()))), wp_kses(__('<i class="fa fa-comment"></i>1', 'masonry-brick'), array('i' => array('class' => array()))), wp_kses(__('<i class="fa fa-comment"></i>%', 'masonry-brick'), array('i' => array('class' => array()))));
		echo '</span>';
	}
}

Now, you might also need to add this CSS code in the Additional CSS Box provided via the Customizer Options to better display the category name in that area:-

.entry-meta .cat-links {
	display: inline-block;
	margin-left: 10px;
}

To remove the author name display form the home and archive pages, you can try this CSS code in the Additional CSS Box provided via the Customizer Options and check:-

.home .entry-meta .byline, .archive .entry-meta .byline, .search .entry-meta .byline {
	display: none;
}

Thanks.
Bishal Napit