How to show all post types in Front Page results

Every day more websites use the Post Types extension of WordPress. They are not publishing just (simple) posts but they publish recipes, people profiles, city reviews, testimonials, or whatever you could imagine. It’s fantastic to be able to works easily with all these kinks of different information both in Front End and Back End however, when you access to your Front Page these Post Types aren’t shown in the results list of the main query. Are they shy? What can we do?

Army Photography Contest - 2007 - FMWRC - Arts and Crafts - A Plumpish Proportion

This behaviour is because of the relationship between the kind of executed WP query and the URL that you are typing in your browser. When you register a new Post Type inside your themes or plugins, WordPress automatically creates a new Continue reading…

Constructing WP themes or plugins that take into account future gender translations

Actually, there is not a simple solution for avoid the gender issue if you are translating a WP theme or plugin to languages that take into account the gender for selecting the words of a sentence. Simple, try to substitute the gendered words or expression for others that feet into the sentence without too many problems… But if you are not translating but creating a new theme or plugin you can use a simple set of techniques –better maybe suggestions–, that will allow future translators for dealing to this kind of problems with better results. Let’s go to see three simple proposals.

Rest area

But, before to go to the solution, let me show you a tiny example of this kind of gender issues. 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…

Configuring WordPress Automatic Background Updates

Automatic background WordPress updates were introduced in versión 3.7 and since then, this module has been maintaining your installation updated and ready for working however in some cases, you don’t desire that your WordPress installation changes without your permission. Perhaps for compatibility with a special developement addition, perhaps for some non updated but critical plugin or any other reason you do need to control manually the WordPress Updates. If this is your case then go ahead but rather it is much better to leave the maintenance module quiet.

Configuring WordPress Automatic Background Updates

As the official documentation explains about the Automatic Background Update Module, this module has 4 different Types of working. 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…

Marking all external links for opening in a new Tab Browser

Normally, it’s while you are writting a post, when you mark the links inside the text as normal or “for opening in a new Tab or Browser” –typically the external links–; simply you mark the checkbox Open link in a new Tab in the Links Tool of WordPress Editor but what does it happen if you have already got a lot of posts non marked, or if you have changed the criteria for external links, or whatever similar situation?

Food Camera and Backchannel: MIT Media Lab lists

Well, the long solution consists of editing all posts and to locate and to correct manually the external links but, if you have more than a hundred of posts with a lot of links probably, it will be an very stressing task, and surely, you’ll forget some of them… 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 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 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…

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…