webappguides
Create Wordpress Theme From Scratch! Build Your Own

How to add an attribute in stylesheet by wp_enqueue_style

webapps log

webapps Lab
December 1, 2020
ThemeFunctions

wp_enqueue_styles add attribute

The wp_enqueue_styles can output the stylesheet with custom attributes.

However, the arguements of wp_enqueue_styles cannot add the attributes to a link tag

So, you should use WP_Styles’s method add_data to put attribute to style tag

Therefore, this post shows how add_data adds attribute to a wp_enqueue_styles

But also, you will add attribute to a stylesheet using style_loader_tag hook

Let’s get started now

Continue Reading

Count the number of posts in the custom post type in WordPress

webapps log

webapps Lab
November 19, 2020
ThemeFunctions

Does your blog posts use tags, category slug, or any custom taxonomy?

If the answer is YES, then it is a good idea to fetch the number of posts in the post type using custom taxonomy

Inside the article, you will learn how to implement WP_Query, wp_count_posts and get_posts to get number of custom post type posts

If you want to count the number of posts in the custom post type, this post has tips for that

Please read the guide to count all category posts

Continue Reading

Remove wordpress style.css from wp_head

webapps log

webapps Lab
November 12, 2020
ThemeFunctions

remove style.css

The wp_head always adds many scripts including unused stylesheets. The wp_head is very essential because it is used by plug-ins to include the libraries and plug-in script. So, you can’t remove the function but the unrequired stylesheet can be removed. One of the styles you may want to get rid of it is style.css. A wp_dequeue_style is able to remove […]

Continue Reading

How to get post title by id in WordPress

webapps log

webapps Lab
November 6, 2020
ThemeFunctions

post title by id

Inside the article, you will find how get_the_title receives the ID to show the title of the page(post)

The article covers the best practise to display the title when the id is used.

But what is the other the function that accepts the post id?

get_post.

If you read the entire article, you will be able to use get_post to get post title by id

Dive in now to find out how the title can be retrieved using the integer

Continue Reading