alexanderdejong.com

Wordpress Developer

  • Home
  • Blog
  • Projects
  • Contact
You are here: Home / Archives for atpdejong

Add Custom Taxonomies to the Body Class

Posted on May 9, 2015 4 Comments

As of WordPress 4.2-alpha-31271 (23 January 2015), CSS classes for custom taxonomy terms are now automatically added by WordPress core when using post_class(). However, they are not automatically attached to the body classes.

You can use the following utility function to add your custom taxonomies to the body class for use as CSS hooks in themes:

/**
* Add Custom Taxonomy Terms To The Body Class
*/

add_filter( 'body_class', 'atp_custom_taxonomy_body_class', 10, 3 );

if ( ! function_exists('atp_custom_taxonomy_body_class') ) {
    function atp_custom_taxonomy_body_class($classes, $class, $ID) {

        $taxonomies_args = array(
            'public' => true,
            '_builtin' => false,
        );

        $taxonomies = get_taxonomies( $taxonomies_args, 'names', 'and' );

        $terms = get_the_terms( (int) $ID, (array) $taxonomies );

        if ( ! empty( $terms ) ) {
            foreach ( (array) $terms as $order => $term ) {
                if ( ! in_array( $term->slug, $classes ) ) {
                    $classes[] = $term->slug;
                }
            }
        }

        $classes[] = 'clearfix';

        return $classes;
    }
}

Put the above code in your theme’s functions.php file. Then, whenever the body_class() is used in a template:

<body <?php body_class();?> >

It will output any public custom taxonomy term(s) attached to the post, in addition to all of the default body classes.

Filed Under: Wordpress, WP Tutorials Tagged With: body_class, CSS, custom taxonomies body class, get_taxonomies

How to redirect a user during logout with WordPress

Posted on May 7, 2015 Leave a Comment

I found a handy redirect function which I would like to share with you all!

If you want a user to visit the the frontpage during logout, place this into your functions.php in your current theme directory:

add_action('wp_logout','go_home');
function go_home(){
  wp_redirect( home_url() );
  exit();
}

A neat trick, if you have php version above 5.3 then you can write an anonymous function which is more compact:

add_action('wp_logout',create_function('','wp_redirect(home_url());exit();'));

Filed Under: Wordpress, WP Tutorials Tagged With: login logout wordpress, login/logout, logout wordpress, peters login redirect, wp admin bar, wp_logout, wp-login php

Frameworks to use with WordPress in 2015

Posted on April 4, 2015 Leave a Comment

JointsWP Framework

It is a solid Framework built together with Foundation. Although, I have never used Foundation yet, it looks like it has a similar grid like Bootstrap (with some more complex grid options), cool buttons and quite a few JavaScript plugins.
Check out JointsWP.

Some like it neat Framework

Some Like it Neat is a starter theme and it is based on Underscores. There is a nifty mixin library for SASS called Bourbon and neat which is a grid framework to build any responsive layout.

Some Like it Neat
Here are some more resources:
Get it from GitHub

Get it from WordPress.org

Roots Framework

Roots is a cool starter framework with lots of functionality, like SASS, better internal links and uses grunt. Roots becomes an even better alternative when you add bourbon.io to the mix.

Get the Roots.io Framework

Other ways to leverage these Frameworks

You could take out really awesome stuff from bones and underscores and put it into your own starter themes!

The Genesis Framework

I’ve been a genesis user for about four years and created lots of small and medium sized websites. It’s a really neat framework, coded very very well! Making it easy to maintain and customize!

FoundationPress Framework

FoundationPress is a WordPress starter theme which is also based Foundation 5 by Zurb. Similar to JointsWP.

NOUVEAU WordPress Framework

This one has really good PHP namespacing and is also based on the Zurb Foundation Framework.
NOUVEAU WordPress Framework

iThemes “Framework”

iThemes is not really targeted at developers and is similar like Divi. The prices/cost of entry are higher and they tend to lock you in! Read more here – Divi Theme Forever.

Bootstrap Genesis Theme

I personally like Genesis because I find it a lean framework and easy to insert content with the hooks it comes with. There is even a release with Bootstrap

Did I miss any Frameworks out there?

What is your favorite WordPress framework to work in? I have been using Genesis for a long time but I would love to hear your suggestions for other platforms.

Filed Under: WP Tutorials Tagged With: foundationpress framework, ithemes framework, some like it neat, wordpress genesis framework

How to Hide the WP Admin Bar

Posted on March 30, 2015 Leave a Comment

The WP Admin bar that WordPress automatically adds to your website when you are logged in can be seriously annoying (especially while you are designing away at your client’s website).

admin-bar

This bar can be frustrating because it can slightly throw off your design and you don’t really need it for anything. Here’s a snippet of code which will prevent that toolbar from displaying, just add it to your functions.php file or a plugin:

Hide the WP Admin Bar with the following php code

add_filter('show_admin_bar', '__return_false');

With this quick hack you don’t need change any CSS and your layout will look as it should. The filtering/hook system is really useful!

Filed Under: WP Tutorials Tagged With: wp admin bar

Will SSL make my Website slower?

Posted on March 30, 2015 Leave a Comment

Google is giving more weight to HTTPS but at the same time Google also wants to penalize for slower websites. And it seems that HTTPS takes longer to load than non-HTTPS.

“Moreover it takes more time to get a HTTPS webpage rendered on Browser when compared to a HTTP webpage. This is due to the required negotiation time of the server to authenticate the GET request.”

They even write that:

“There is absolutely no need to serve a HTTPS webpage, when there is no question of any privacy.”

So for non-memberships sites you wouldn’t need to serve HTTPS pages. It makes it really questionable what is the best thing to do. Joost de Valk did the transition awhile back. The document on WordPress has been written a while ago, however the push from Google is quite recent. There is a global need for better online security in particular with websites running on WordPress or Joomla.

Why use SSL?

Trust factor is a big part of using SSL on your website, when a visitor sees that you have taken the effort to get your organization verified or at least have a trusted “green padlock” in your url then things seem more legit. The painful thing is when you keep receiving the mixed content messages. So you have to be very thorough in making sure everything is being delivered securely.

There are many other factors at play in ranking. Page load time does impact the way you rank, but its not a main factor and certainly not the only one. Other things such as a good Schema.org markup can improve your ranking as well. Yoast has the following experience with SSL and SPDY:

So. HTTPS doesn’t have to be slower, there’s obviously a tiny bit of overhead but then things like SPDY are actually faster than “old” HTTP implementations.

If you need HTTPS on a part of your domain, doing it for the entire domain means you can cache resources much more easily, use a CDN better, etc. So… Just make the move.

Google’s SSL SPDY could be a solution

Well, you can only use Google’s SPDY if you have your own server. If you don’t you could use CloudFlare. They have been offering SPDY to customers with SSL since 2012. If you switch over full SSL be sure your cdn supports SPDY or else you will reduce the speed of your website. SSL will make your site slower unless EVERYTHING is loaded over SPDY. And it depends on how your SSL has been configured.

Should you make the switch?

Probably, just make sure your Google Ads keep working, your files are loading securely, you change your HTTP links into HTTPS etc etc.

Filed Under: WP SEO

How to style two different blog pages in the same WordPress site

Posted on March 30, 2015 Leave a Comment

It’s quite easy to build two different styled blog themes on your WordPress website. You could do this by leveraging the Multi-site functionality of WordPress. Another option is to add a CSS class to each blog post for each category or tag. If you think this will make things confusing for the admin user then create two Custom Post Types (CPT) with their own taxonomies. In this blog post we will go through the various options available and their benefits.

Create a category and style the class to your taste. Or add a custom style to the post.

This would probably be the easiest way to do this. Just open up your single.php file and find the following line of code:

<div id="content" role="main">

Change this line of code to the following:

<div id="content" role="main" <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>">

The following classes are added by default:

.post-id
.post
.attachment
.sticky
.hentry (hAtom microformat pages)
.category-ID
.category-name
.tag-name

The output would look like this:

<div id="post-4564" class="post post-1264 category-18 category-dancing logged-in">

Let’s say your category name is webdesign and you would like to change the color of your Blog Title. You can simply add the following css to your style.css file.

.category-webdesign .entry-title h1 {
color:#000;
}

This method allows you to experiment with different ideas. You can:

  • Style Posts Based on Authors
  • Style Posts Based on Popularity using Comment Count
  • Style Posts based on Custom Fields

This is the least intrusive and quickest fix to changing the design of your category post.
However, it only allows you to add custom CSS. To rearrange the template you would to go a completely different way.

Creating a Custom Post Type to style blog (posts)

From a purely administrative perspective, the main benefit to CPTs is that admins can see a separate section for each CPT and can create a blog post, they would go to their own panel, one for each CPT. You can label each CPT with the names of specific individuals. Using that and a plugin to control Account Capatability (like Capability Manager ) would help to differentiate the two separate blog approach. You can even create a separate homepage with different WP query filters to show different content. Then you just add Taxonomies and the site url goes yoursite/custom-post-type/taxonomy. But if you want the single posts in each category to have another design then you will have to add some custom body classes and a unique template. It will take a couple of hours to do at least.

Use a Multi-site installation to style two different blogs

Just add one in a separate directory and install it from there.



Update for other methods mentioned in this post planned for next week April 7th 2015.

Filed Under: WP Tutorials

Do you leverage broken sleep for creativity?

Posted on February 16, 2015 Leave a Comment

We all have specific sleep patterns, some of us don’t work from 9-5 and have our sleep pattern return to what may be a more natural state. Which includes waking up in the middle of the night. Think about how creative you could be by waking up halfway through the night to think, write or make love.

You could be having a period in which you work till 5 am and head to bed at 6am. Even though this is generally frowned upon by most people, it could turn out that this method of working is super efficient for you! This natural phenomenon could be extremely useful to leverage.

Here are some comments I have collected from other freelancers

I often work till about 4 am and sleep in one block between 6-8 hours. I get things done at night: no distractions and everything around me is calm/silent -> Bliss.

First sleep is 3-4 hours long, then I’m awake for 1,5-2 hours working or reading and then I get tired again and sleep another 2 hours more or less. Never need an alarm clock, always can get up on the programmed time.

As a digital nomad, you could embrace this lifestyle and segmented sleep patterns. Its not for everyone of course, but can be useful to leverage when you are working on an international level. In fact, one famous DJ I know always travels and lives according to his local time. Going to bed at 3am in the morning which translates to 11pm in the night back home. Just know that you share these patterns with millions of other people.

Filed Under: Life Tagged With: sleep, work ethics

Should you give your Admin password to a developer?

Posted on February 15, 2015 Leave a Comment

When you are hiring a developer to develop a (child) theme you may be asked for admin access to your WordPress website. A few options will come to mind, you can create a new account and give him login details or hand him access to your account, but what is really the best thing to do?

You could have him setup a new site for you

You might want to create a separate copy of your site. This way you can have your developer work on a non-live version of the site and it will not interrupt the user experience. In the WP community we actually call developers who work on live sites “coding cowboys”. It’s really not the best way to go!

You should have the developer work in their own digital environment

The best thing to do would be to have them develop on their own domain and when it’s ready then they can just send you a backup of the site or upload it live without much interference for the user!

If you do decide to give complete access then be VERY careful. If the theme + plugin developer is not qualified then you risk having all your work and content ruined. Any seasoned developer will always make a full backup of the site before changing any code!

A developer can also do most of the work offline, but I think its better to do it on a live server configuration because by using the same configuration you can be sure that everything will work very well!

Filed Under: WP Business Tagged With: coding, copying, development

Should you use www in a website’s URL?

Posted on February 15, 2015 Leave a Comment

The www can look better for shorter domain, however some people may argue that it looks old fashioned. You should however consider very careful whether to keep the www in your domain not only for visual reasons but also for SEO. If your site was a domain authority then removing the www could have
a negative impact on your rankings. Most developers should be advising you to keep the www if you have been using it for a long time already.

If you do decide to remove the www then make sure you set up a 301 redirect and you will not lose much link juice. Rankings can get erratic after migration but its difficult to show any resources on whether this really happens. (Google tends to keep secrets quite well). Yahoo and Bing don’t handle 301’s as well and they still are important sources for traffic.

www, url, using www

Do you really want the extra work?

Actually there is no reason to drop the www on an existing blog because it just leads to extra work because old links might break. Check out this link on MOZ to find out more about this.

You should definitely use www if you are using a load balancer and need a CNAME point and if you are running an app with several tools. Or if your SSL issuers don’t issue a single cert for both www and non-www. Symantec is one such.

One tip I do want to give is if you are using Google Webmaster Tools then please set up your preferred domain to the site you are using.

Filed Under: Business

Are Coworking spaces proftibale and when should you (not) use them

Posted on February 15, 2015 Leave a Comment

I always see a lot of posts asking about co working spaces to visit in cities that I have been to. And it’s no surprise that after Airbnb for accommodation also plenty of sites have popped up for Coworking such as Copass or paste any other co working site here.

During my stay in Milano, I also lurked around to find some proper co working spaces. But lots of these spaces are overpriced, out of the way or simply don’t offer much value. In the end, you are just looking for a cool place to work from without spending so much money. When I travel I try to visit a coworking space at least once. But when the commute is more than 20 minutes or so, I just head to cafe considering that most people I meet in coworking spaces are not nomads like myself. There are a lot of beta-ish sites with too few listings on the web that you can browse such as workfrom.co, cafes.io, cafes4nomads.com, deskzero.co and wificafeguide.com. I don’t understand why they just don’t work together on the whole plan. We NEED a more community based approach like hitchwiki!

Anyways, to make a long-story short. I cancelled the co-working spaced contract and went back to working from home and cafes. I figured its better to spend that money on going to the gym which is more expensive if you don’t take a yearly contract!

working from a cafe

Why you should not use a co-working space? Because cafes are:

  • Cheaper
  • More Social
  • Provide service (they bring you coffee and food)
  • Located in better spots
  • not so lonely

However, co-working spaces can be a melting pot of great ideas and cool place to network. Just not my cup of tea!

Filed Under: Business Tagged With: community, coworking

  • « Previous Page
  • 1
  • 2
  • 3
  • Next Page »

Recent Posts

  • Migrating a WordPress Website Manually with Phpmyadmin, Search and Replace, DigitalOcean and Runcloud
  • How to add Total Price Calculation to your WooCommerce Product Page with AJAX
  • How to Install Roots Bedrock on a Digital Ocean Droplet running on Serverpilot via SSH
  • Linux SSH Useful Server Commands to Remember: Grep, Permissions and more.
  • How to Install Roots Sage 8.5.1 on a Digital Ocean Droplet running on Serverpilot via SSH

Find more content

Affiliate links
  • cheap shared hosting
  • low priced virtual servers only 5$
Affiliates
  • If someone buys a product then I get a commission.
  • You pay the same price using my affiliate links.
  • I can spend more time making newsletters and tutorials.
  • Thanks for visiting!

Connect with me

Recent Comments

  • Pedro Gómez on Migrating a WordPress Website Manually with Phpmyadmin, Search and Replace, DigitalOcean and Runcloud
  • Tim Delmeire on How to add Total Price Calculation to your WooCommerce Product Page with AJAX
  • Jaehyuk J Yang on How to add Total Price Calculation to your WooCommerce Product Page with AJAX
  • Alexander de Jong on A guide on customising the membership experience with Theme my Login (TML)
  • Judit Sarkany on A guide on customising the membership experience with Theme my Login (TML)

Recent Posts

  • Migrating a WordPress Website Manually with Phpmyadmin, Search and Replace, DigitalOcean and Runcloud
  • How to add Total Price Calculation to your WooCommerce Product Page with AJAX
  • How to Install Roots Bedrock on a Digital Ocean Droplet running on Serverpilot via SSH
  • Linux SSH Useful Server Commands to Remember: Grep, Permissions and more.
  • How to Install Roots Sage 8.5.1 on a Digital Ocean Droplet running on Serverpilot via SSH

Copyright © 2014 | Alexander de Jong | About | Contact | Privacy | Sitemap