How to style php snippets echo

[ad_1]

Hi @anas33chaudhary,

In order to style the output of that code you will need to wrap tag names, for example, in an HTML element with a class so that you can target it with CSS styles.

Here’s an example of wrapping the whole thing in a div and each tag in a span element:

$tags = get_tags();

echo '<div class="tags">';
foreach ( $tags as $tag ) {
	if ( $tag->name == 'fill' ) {
		continue;
	}// do this for every tag you want gone
	echo '<span class="tag-name">' . $tag->name . '</span> ';
}
echo '</div>';

After making this change you can use a CSS snippet to target those elements, here’s an example using CSS:

.tags {
font-weight: bold;
color: #222;
}
.tags .tag-name {
display: inline-block;
margin-left: 5px;
}

Depending on your theme you might need to make the class names more specific to avoid conflicting styles.

You can read more about using CSS in WordPress in this article.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer