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…

Loading a language translation in a Child Theme

When we need introduce some changes in the behaviour, features or style of the theme that we are using, Best practices in the WordPress environment advises us to never change the principal theme but writting a small child theme containing those modifications. In that case, when those modifications show text on the screen, of course we can opt for outputting directly this text but it’s usually better to use the translation functions. But then, How to read a child theme translation keeping the principal (parent) theme translation?

Loading a language translation in a Child Theme

The solution is very simple because in fact there are two different functions to do that. For reading the translation of the parent theme, we have to use the function called load_theme_textdomain however, for reading the translation of the child theme 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…

Adding a fixed text or element to all posts. The “the_content” filter

We often need to add a fixed text or html element to the text of all posts: a signature, a link, a little logo, even a form. In fact, there are some ways to do this task but perhaps the easiest way is to use the the_content filter.

Basic schema of operations for the_content filter

The the_content filter –in general any WordPress filter– is a kind of funnel through which WordPress passes the post_content before being displayed on screen. Using this funnel (filter), ie, adding operations inside it, we can change de content of the post_content field for all Posts but for doing this we have to do two operations. Continue reading…