Changing the user’s Contact Info fields

By default, WordPress still maintains very old contact info fields for users so the most probable is that you want to improve them and, on the other hand, despite of some themes or plugins have already made this change, probably you don’t want either that these improvements depend on one installed theme or plugin but rather they always keep available.

Improving User’s Contact Info

So, in this example, we’re going to develope a simple plugin that makes three different things Continue reading…

Using wp_add_inline_script function. A Google Analytics example.

Until version version 4.4, in WordPress, there was only one way to add script files to the WordPress themes, the function wp_enqueue_script however, the new version 4.5 has introduced a new way, the function wp_add_inline_script that allows us to add javascript text scripts directly inside a template and that, in addition, it can be directly connected with other scripts. Let’s go to see how it works.

Example of using the wp_add_inline_script function

At bottom, this new function wp_add_inline_script is the equivalent for scripts files, to the wp_add_inline_script function is for CSS files. Let’s see how it works through and example based on adding the Google Analytics script to a WP theme. Continue reading…

Showing posts with different templates, the “single_template” filter

Habitualy, the WordPress template hierarchy for posts, uses a simple descendant decision tree for choosing which single_template.php file is going to be used for showing a single post. This decision tree is quite usefull so that, simply creating a .php file called like single, single-posttype, etc., it’s possible to control very accurately which template will be used for showing data.

Normal Decision Tree for Single Elements

However, in contrast of pages that each one can have its own template, ie, they have a very flexible decision rules, choosing the templates for posts is ruled by criterias more restrictive based in sets of elements Continue reading…

How to move jQuery script to the Footer

As default, WordPress actions put the jQuery scripts in the header of all HTML pages however, sometimes it is necessary to move these scripts to the footer of the page but a simple movement is impossible. As jQuery script (and dependents) is defined by WordPress during the first steps of its loading, when you try to redefine later its output through wp_enqueue_script( ..., $in_footer TRUE ) or similars, you haven’t got any result.

Designing a new feature, with jQuery!

There are some methods to make this change, some more risky, others more conservatives. Today, I’m going to show two methods very simple and quite conservative based on Continue reading…

How to suppress the emoji module?

As the WordPress documentation says, Emoji are the ideograms or smileys (for example 🙂 ) used in electronic messages and Web pages. Originating in Japan on mobile devices, they are now commonly available on devices worldwide, ranging from mobile to desktop computers. Emoji are decorative, useful and they can actually make any website more friendly, maybe for this reason, the Emoji module is added as default by WordPress to all Themes but, what can we do if we don’t want to load this module?

Emoji keyboard example for Android by Kraftbj on WordPress

The WordPress Emoji module is independent of any theme, and just depends on two files (a little CSS code and a script) that are tipically added to the HTML <head> element. This addition is made through two functions Continue reading…

How to add the google-site-verification code or other API parameters to your WordPress themes

Webmasters Tools of Google is a set of useful utilities that allow you to control a lot of elements of your website and among them, specialy the reading of the list of your pages through the sitemap.xml file. It is really a fantastic tool for your SEO so I’m sure that you want to connect with it. For connecting your site with an specific Webmaster Tools account, google offers you several methods but, perhaps the easiest is the addition of an HTML meta tag in the HTML <head> of your pages containing the google-site-verification code. Today we’ll see a method for adding automatically this google-site-verification code in a theme and for extension, for adding any API codes, third party parameters, etc.

How to add the google-site-verification code or other API parameters to your WordPress themes

In fact, every day is more common to use APIs to access from your web to services offered by outside webs so I do really suppose you want to use easily the associated codes to all these APIs in your Themes. Continue reading…

How to order the Replies of the Comments

WordPress has a good interface for ordering and showing the comments of a post for the themes. You simply have to do click on the Admin’s menu Settings / Discussion and in the section Other comment settings, the last two lines offers you three fields for controlling it: number of comments for each page, which page is shown in first position (the last or the first) and, of course, the order of the comments (older or newer comments) for each comments page… But, what about the replies of each individual comment? How to control if these replies are displayed in ascending or descending order?

How to order the Replies of the Comments

Though in terms of data type, comments and replies are the same, due to their hierarchical structure,  Continue reading…

How to modify the FavIcon links of the function wp_site_icon in WordPress?

Since version 4.3 WordPress introduces the ability to add a Icon automaticly to your site through the Customizer / Site Identity module. In fact this icon is known as the FavIcon and it is based in a very fuzzy and changing specification that, in addition, depends on the devices to what the favicon is prepared for, so WordPress developers team has logically opted for an very standard HTML output for favIcons. This standard HTML output works but perhaps you want to improve, extend or adapt it to other devices or programmes that are going to read it and use it. (See the next examples).

New Gmail favicon

favicons

Favicon for the Birdies 100 blog

There are several methods for changing this HTML FavIcon output and include improved sentences for its definition, ones more radicals, ones more WordPress code friendly, but in this example I’m going to propouse one method based on the conservative approaches so I’ll use a filter instead of redefine the list of actions attached Continue reading…

Controlling the WordPress version installed inside your Themes

WordPress is a CMS that evolves rapidly. Currently, every four or five months there is a new version and this makes important to introduce in your developments some control to find out what is the installed version, especially if you want to use its latest introduced features and you want that your last development has backward compatible.

Controlling the WordPress version installed inside your Themes

Fortunately, WordPress makes it very easy because for not even you’ll have to use a function but there is a global variable called $wp_version that is always available in any part of your development that contains Continue reading…

Modifying the HTML <title> tag in a WordPress Site

As default, WordPress automaticaly generates quite good HTML <title> tags for the different pages of a website. These HTML <title> tags usually fit well with the content of the page and for us, the human beings, these tags are more than enough for understanding. On the other hand, these HTML <title> tags (hereinafter simply, titles) are also interpreted for the programmes: the browsers just show these titles but web crawlers engines use titles for understanding the global meaning of the content and, depending on them, the pages are classified and included (or not) in the results of a search and this last it’s very important if we are talking about SEO. Good title, good SEO. Poor title… well, you know. So the most probably is that you want to improve a litle bit your HTML <title> Tag. Do you want?

Modifying the html ‘title’ tag

Time ago, for modifying the titles WordPress only offers one posibility, to filter the output of the function wp_title however, since version 4.1, WordPress also offers another possibility, Continue reading…