Category Archives: Tips and Tricks

Now using Github for WordPress template code

Thanks to the generosity of Joseph Moore, giving his time to help/make us understand the philosophy and practical steps of using Git, in particular Github, we now have a structure to the development of our WordPress template code.

If those words – Git, Github – don’t mean anything to you, they might well do in the future.

Control over changes
Git is a way to strictly control changes over things. I use the all-encompassing ‘things’ because it not just code (Git’s roots), because graphics and other files can be included. It’s also not just code. Git is also expanding beyond its familiar use in code, to other writing as well, as demonstrated by GitBook.

We’re using it to control the version of code and graphics that make up our WordPress template – and hence the display of our publication to the public. Initially our mobile-specific WP theme.

It brings the discipline to ensure that any changes made to the template are incremental, while bringing added advantages like you don’t litter the code with changes comments. It also brings the advantage of a central backup of the code.

Branching
‘Branching’ is intrinsic with this Version Control (which Git is an instance of), meaning that code can be safely developed by more than one person, in more than one location, without those distributed changes overwriting each other.

Dropping /YYYY/MM/DD from WordPress URL and successfully redirecting

I wanted to drop the Year / Month / Date part of the URL from the Cafe Scientifique site, so what would previously have been
http://cafescientifique.onthewight.com/2014/06/11/barry-arnold-story-chocolate-science-serendipity/
becomes

Barry Arnold: The story of Chocolate: Science and Serendipity

We just didn’t need to know in the URL what the date of the posting was.

Not wanting to lose any URLs that might have been referenced elsewhere, a Redirect Rule was needed.

RegExp code for Redirect Rule
John P. Gamboa and James Gardner at WPE were heroes forming the RegExp needed to do they job. We ended up with

Source: ^/(\d*)/(\d*)/(\d*)/(.*)/?$
Destination: /$4
Domain Wildcards: cafescientifique.onthewight.com

As James pointed out, it was the fourth string that we needed to be used.

Permalink Setting has to be changes from ‘Day and Name’ to ‘Post name’ as well (of course!).

It working
So now
http://cafescientifique.onthewight.com/2014/06/11/barry-arnold-story-chocolate-science-serendipity/
resolves to
http://cafescientifique.onthewight.com/barry-arnold-story-chocolate-science-serendipity/
and none of the other subdomains are affected. Perfect.

How to merge or change a WordPress Category to a Tag

Edit Category – Copy out text of Description / SEO fields in to a text editor (This can/will be lost in the conversion)

_Setup redirect rule for old category
eg to Forward http://onthewight.com/business/solent-lep/ to http://onthewight.com/about/solent-lep/

Use:
Source as ^/business/solent-lep/$
Destination as /about/solent-lep/

_The conversion
Enable Taxonomy Converter plugin

Select ‘Convert’ and tick ‘Tags’
Pick the Category that you’re looking to merge / change to a tag
Click the Go button at the bottom of the page

Edit the destination Tag – Include all of the text you copied out of the previous Category. Save

Disable Taxonomy Converter plugin