Showing the Last Updated Date in wp Posts or Pages

One of the most important things currently is to be up to date, offering contrasted information and, above all, that has not become obsolete. Most WP themes show the date on which an article was created but … How can a visitor know if that content is up to date?

Computer Tapes

The answer is to show, in addition to the date of creation, the date of the last modification of any wp content. In this post I’m going to show how we can do it in a very simple way. Continue reading…

Creating a Table of Contents for your Pages

WordPress has got the hability to work with nuclear posts and also with posts that can contain other posts, ie, posts with hierarchical structure, the pages. Today we’re going to see how to create a hierarchical list of the second ones, as an index of pages, Table of contents (TOC), etc.

Panzerbaum

As default, WordPress supports two different kinds of elements: posts and pages. The basic difference between them is that the first ones are treated as individual elements and thus, when WordPress displays a collection of them, this will be just a long linear list of elements (like the natural numbers 1, 2, 3, 4, for example) meanwhile the second ones have got a hierachical structure, ie, each element can contain (to point to) elements that have also got hierarchical structure and can contain (to point to) other elements and so on, in consequence, when WordPress displays a collection of them, it should be always presented as a tree and never as a list. Continue reading…

How to detect when get_template_part() WordPress function fails

Nowadays, in most of modern WordPress themes, the function get_template_part() is one of their essential elements. It just takes review the structure of, for example the last official themes (…, Fourteen, Fifteen, Sixteen), to realize that WordPress themes have evolved, from a structure quite monolitic to a structure driven by content and formats. And one of the keys to this evolution is the get_template_part () function.

silent diversity

get_template_part() it’s actually an invaluable element of any modern WordPress theme that through its two parameters allows us to select dynamically what .php file (what part) is going to be loaded for displaying the current page (see the official documentation for further information) however, one of its characteristics is that Continue reading…

Selective enqueueing of WordPress scripts and styles through conditional loading

Both in front and back end, WordPress themes and plugins usually enqueue styles and scripts; the real cornerstone of the our work. Security systems, communications, silent or programmed operations, intelligent data process… Most of these common operations have in their backgrounds the loading of scripts and styles. Today we’re going to see how design a selective loading of these components.

Big, big tires

Habitually, the loading of scripts and styles is made by themes and plugins through the functions.php and the /root-plugin-folder/plugin-name.php files respectively. In both cases, usually there is (are) a little function in these php files that programmes the loading of all of these essential components. Continue reading…

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…

Strategies for URL redirection in WordPress front-end pages

I know that is not a common situation but sometimes it’s necessary to redirect the current page to another URL. Inside WordPress back-end is relatively simple but from the WordPress front-end templates that shows the Posts, Pages… It’s a little more complicated.

Change direction

In this article we’ll see some strategies for redirecting the URLs, all of them based in using the WP function template_redirectContinue reading…

Using the Post Type description in WordPress Themes

Sometimes, especially in the case of an items list, apart from the header/title of the list, we would want to add some text as an introduction for these items: a global suggestion, perhaps a couple of interesting links, a descriptive or in detail approach about the items, a definition, etc. When the items to list are inside a Category or a Tag, to add a header with description is obvious because, simply taking a look to the screen for editing terms, all of us know that they have a description but, do you know that post types have also got a description, and that you can use it in your themes?

An example of using the Post Type description in WordPress Themes

Yes, in the same way that with the terms of a taxonomy, WordPress Post Types have also got a field to add a description thus, you can use this property of the Post Type object to introduce any text that you want and Continue reading…

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…

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…

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…