Using Post Formats with your custom WordPress Post Types

Since versión 3.1, WordPress introduced a new theme feature called Post Formats that, basically, allows us to divide a regular WordPress Post Type in subsets based on the nature of the information that a post includes, ie, you can have regular posts, but you can also have posts that specifically contain a video, or an image, etc. In case of the Post Type post, most of the popular WP themes already includes support for styling its Post Formats but, what can we do for using Post Formats in case of our custom Post Types?

macarons

The proposed method is quite easy and it simply extends the habitually used technic for dealing with Post Formats inside WordPress templates, in other words, we’ll create a refined system for loading the content-{$post_format_slug}.php subtemplates. Continue reading…

Social Menus with Genericons

As a tiny module that follows WordPress very closely –it was included in the Twenty Fifteen Theme for example–, but not as a part of the official WP core, Genericons is an icon font very useful if you are thinking in creating a Social Menu. Well, this font includes a lot of good icons for other tasks but a third part of its icons are designed for giving support to social extensions.

Social Menus with Genericons

Using Genericons, to create a social menu for example similar as the installed in this web site, it is so simple as enqueueing the Genericons Font, creating a new WP menu and deciding which social profiles you desire to include. You don’t need to add a special code, or modify substantially your themes 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 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…

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…

Using Dashicons in WP Themes

Dashicons Font is a wonderful and useful set of icons included in WordPress since its 3.8 version as part of its new admin environment. WP uses these icons to identify posts, media tools, editor tools, etc. In admin environment you have not to do anything for loading this set –it is loaded by default by WP–, however Dashicons Font is not loaded as part of any theme. So, what do we have to do for using Dashicons inside our themes?

WordPress DashIcons Sample

Nowadays, most of browsers allow us the use of fonts for improving the appearance of our pages and this feature is supported via CSS Continue reading…

A different style for the external links

Sometimes inside a post or a page you have to include a link whose url doesn’t belong to your website; a external link is called. In most cases, this kind of external links are styled in the same way that the rest of internal links (links to your own website) and, in consequence, the readers can’t distinguish between them. Now, a simple method for styling your external links.

Styling external links in a different way. An example.

Our first step is to find out what is the basic difference between these two kinds of links because  Continue reading…