Home » Development » WordPress » Page 8
Many developers hesitate to call WordPress a PHP development platform. I know what I am talking about, as I developed a platform of my own. PHP platforms normally only provide a skeleton and we need to
With WordPress you get most of this out-of-the-box, with some predefined structures.
Having a flexible administration backend in place makes it easy to concentrate on the things that matter for a project, which is designing a frontend experience.
And especially with the JSON REST API finding its way into the core slowly, you are completely free when it comes to using the stored data in your frontend designs.
Sure that was possible before, just with some more work on our side ;)
But WordPress embracing the “freeing of data” through JSON, shows us where the ride is going.
There has not been a single project of mine in the past year, that has not used the REST API in some way. And all of this fits perfectly into the new single page app universe.
It has become much easier and faster over the past 2 years to say “YES” to many of my clients wishes.
Its nice to finally see data flow from the server to the client and back that easily.
If you are not exited about this … I am :)
In a current project I am using pages as templates, to load content into specific containers on the website. The website will be using up to 15 different languages.
The main language setup is done through WPML, which creates linked content per language. This helps, as some languages will fail terribly when translating them through a pure gettext setup, as the words setup is often completely different.
But there is always static stuff that can be translated directly through the language files. For that I use a simple shortcode that allows me to keep the native language as a basis in all linked content. Easier to move around, as I can actually read and understand it :)
Call the shortcode from the functions.php
The shortcode function itself. This loads the language textdomain from the specified location and translates the string.
How to use it in your post or page content
Conditional Tags are a powerful thing in WordPress and especially handy to show or hide things.
“The Conditional Tags can be used in your Template files to change what content is displayed and how that content is displayed on a particular page depending on what conditions that page matches. ”
Two plugins are part of my essentials, that utilize the Conditional Tags:
You can easily define your own Conditional Tags in your functions.php or plugin.
“NextGEN Facebook (NGFB) gives you total control over the information social website crawlers need, improving Google Search ranking, social engagement, and click-through-rates on Facebook, Google+, Twitter, Pinterest, LinkedIn, StumbleUpon, Tumblr and and many more”
A powerful plugin for WordPress, but it sometimes displays many image dimension errors. Even if those errors remind me to optimize the page or post, I sometimes prefer to ignore these during development :)
Here a simple way to hide them:
Adding Metaboxes in WordPress to your admin areas normally involves 3 steps:
This can be done much easier using Custom Metaboxes and Fields for WordPress, which is a metabox, custom fields and forms library. The library provides a bunch of custom fields and also allows you to add your own easily. Much easier to build new Metaboxes fast!
List of field types included:
Simple example from the CMB2 Github page
The current Google Analytics Dashboard for WordPress integrates no Opt-Out to disable tracking, which is required in Europe. Here is a workaround for that.
Paste this into your theme function.php.
Then add this to your data privacy document:
When the defer attribute is present in the script tag, it specifies that the script is executed when the page has finished parsing. A requirement that is enforced by Google for example (Page-Speed ranking).
Currently the WordPress wp_enqueue_script provides no easy way to add new attributes, but there is a way around that :)
The below hack / filter needs to be added to your theme function.php. The filter should be your preferred solution, as the clean_url filter has been deprecated.
Make sure that your website / theme is still loading after adding these changes. If needed you can add more exceptions, as I did for jQuery.
Hack for WordPress before 4.1
Filter for WordPress 4.1+
Updated: 26.04.2015 – using clean Regexp
Compressing your content saves bandwidth and improves render time, particular on devices with slow internet connections. Compression allows your web server to provide smaller file sizes that load faster for your visitors. Compression of your HTML and CSS files with gzip typically saves around 50 to 70 % of the file size.
A good candidate is the WP Far Future Expiration Plugin ,which not only activates GZIP compression but adds file expiration for various static file types.
Check speed improvement before and after
I had a problem with the tag pagination throwing 404 errors and was forced to integrate a custom query into the 404 page, while fixing the rewrite rules ;)
This is how you force a different HTTP response header with WordPress, in this case a simple HTTP/1.1 200 OK.
Some tweaking to add your own classes to the body tag
As part of our complete network upgrade, portalZINE.TV gets a complete facelift as well. The whole website has been streamlined in preparation for the new season.