How to count total words for posts published by one author in WordPress?

Posted by Prem Tiwari | Updated on | WordPress


If you want to count total words for posts published by one author in WordPress? Use the below example code with translation support. Source: File: wp-includes/user.php

Author posts not appearing for custom post type in WordPress

Posted by Prem Tiwari | Updated on | WordPress


Author posts not appearing for custom post type in WordPress. I managed to resolve this issue by using pre_get_posts function and adding the custom post type to the main query. I added the below to …

How to set focus on an input field after rendering?

Posted by Jennifer | Updated on | WordPress


Want to set focus on an input field after rendering? You should do it in componentDidMount and refs callback instead. Something like this:

Sanitise in WordPress but keep html

Posted by Prem Tiwari | Updated on | WordPress


Sanitise in WordPress but keep html. wp_kses() will do what you need. You need to tell it what tags to allow. Alternatively use wp_kses_post() which allows anything you can add to a post. This one …

WordPress session variable not working

Posted by Pinki | Updated on | WordPress


WordPress session variable not working. Just hook a function on “init” in your functions.php like this:

WordPress Rest Api Custom End point

Posted by Prem Tiwari | Updated on | WordPress


WordPress Rest Api Custom End point. I guess it because you used d metacharacter for regex (?P\d+) that’s mean for digit, please try use S instead. The code should look like this:

How to change the output of last item in loop (ACF)

Posted by Pinki | Updated on | WordPress


If you want to change the output of last item in loop (ACF) You need to count the total fields in the repeater: then have a field counter to check if the current “counted” field …

Favicon using WordPress

Posted by Pinki | Updated on | WordPress


Favicon using WordPress. If your wordpress version is 4.2+, just add wp_head() in your header.php between tags: You should be able to change the favicon from Administration Screen > Appearance > Customize now.

How to use Rest API in WordPress?

Posted by Pinki | Updated on | WordPress


If you want to use Rest API in WordPress? You can use wp_remote_get() For example: You can also control all request parameters like headers and body data:

How to show recent posts from a particular category in sidebar

Posted by Prem Tiwari | Updated on | WordPress


If you want to show recent posts from a particular category in sidebar.Probably easiest to make your own recent posts widget with one of Otto’s php code widgets http://wordpress.org/extend/plugins/php-code-widget/ and a new query: Style it …

How to convert object to array to get the data?

Posted by Pinki | Updated on | WordPress


Want to convert object to array to get the data? It is just normal object access: But it depends on what you want to do. I suggest to have a look at the get_posts examples. …

Remove Category Base from WordPress Category URL

Posted by Prem Tiwari | Updated on | WordPress


In this example, I will share how to remove Category Base from WordPress Category URL. Use the following example code to remove Category Base from WordPress Category URL.

wp_dropdown_pages as an option in my widget

Posted by Prem Tiwari | Updated on | WordPress


wp_dropdown_pages as an option in my widget. You need to give wp_dropdown_pages a proper name attribute (and id would be nice for your label element). This should be like:

How to change the AMP Endpoint in WordPress?

Posted by Prem Tiwari | Updated on | WordPress


How to change the AMP Endpoint in WordPress? If you don’t want to use the default /amp endpoint, use the amp_query_var filter to change it to anything else.

How to hide the site text and just show a logo on AMP pages in WordPress?

Posted by Prem Tiwari | Updated on | WordPress


Want to hide the site text and just show a logo on AMP pages in WordPress? If you want to hide the site text and just show a logo, use the amp_post_template_css action. The following …