Monday, 20 May 2019 06:32

Wordpress and Git

As a freelancer there hasn't been too much need for me to use Git - But all that's about to change. I'm jumping into the deep end, and documentaing my journey. here we go:

Here's an excellent overview of what we will be doing. It includes links to two developers solutions:

The first solution detailed in the above blog post is quick linked here:

Wordpress Desktop Server

It suggests using Wordpress Desktop server to create a local environment. I'm already used to using wamp and mamp - but in order to follow the instructions in the blog post I decided to give Desktop Server a shot.

I was successfull in creating a new local wordpress environment, although importing an existing website into Desktop Server has proved to be a pain. The frontend and backend are displaying PHP warnings, and the wordpress login isn't displaying at all.

Published in Blog
$counter = 0;
$Accordion_heading_1 = get_field('Accordion_heading_1');

<section id="accordion-1" class="accordion">
<div class="container">
<?php if ($Accordion_heading_1) { ?>
<h2><?php echo $Accordion_heading_1; ?></h2>
<?php } ?>
<div class="accordion" id="accordionexample">


// check if the repeater field has rows of data
if (have_rows('tab_1')):

// loop through the rows of data
while (have_rows('tab_1')) : the_row(); ?>


<div class="card">
<div class="card-header" id="heading<?php echo '-' . $counter; ?>">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse"
data-target="#collapse<?php echo '-' . $counter; ?>" aria-expanded="true"
aria-controls="collapse<?php echo '-' . $counter; ?>">
<?php the_sub_field('question'); ?>

<div id="collapse<?php echo '-' . $counter; ?>" class="collapse"
aria-labelledby="heading<?php echo '-' . $counter; ?>" data-parent="#accordionexample">
<div class="card-body">
<?php the_sub_field('answer'); ?>

<?php endwhile;

else :

// no rows found




Published in Blog
Sunday, 16 September 2018 00:42

Dynamic responsive alternating grid squares


  • Bootstrap 4 to create the grid columns
  • Flexbox to create the perfect responsibe squares that contain content
  • Wordpress plugin: Advanced Custom Fields to create a repeater field. The repeater field creates a pair of squares (an image square, and a text square). The repeater field contains sub fields for the various elements of the content (background image, heading, text, link etc)

Code over here

Published in Blog

Use the following snippet to display the URL of a custom post types taxonomy term. Just replace the word position with the name of the taxonomy.

$terms = wp_get_post_terms($post->ID, 'position');
foreach ($terms as $term) {
echo get_term_link($term);

Published in Blog

To display the results of a Toolset Types checkbox field, use the following in your PHP template:

$checkbox_value = types_render_field( "my_checkbox_field", array( "separator" => ", " ) );
echo $checkbox_value;

Taking it a step further, we can create conditionals based on values collected. In the following example I have four values:

$blacktown = types_render_field( "localities", array( "option" => "0" ) );
$carlingford = types_render_field( "localities", array( "option" => "1" ) );
$emerton = types_render_field( "localities", array( "option" => "2" ) );
$penrith = types_render_field( "localities", array( "option" => "3" ) );

if ($blacktown) {
// do something
if ($carlingford) {
// do something
if ($emerton) {
// do something
if ($penrith) {
// do something

Published in Blog
Friday, 16 March 2018 00:05

Stop google from indexing wp-includes

  1. Open a plain text editor like notepad
  2. Paste this line there: 
    Header set X-Robots-Tag "noindex"
  3. Save as .htaccess (yes, there is no "file name" and after the dot, the htaccess part seems to be the extension)
  4. Place it into the wp-includes directory on your server.
Be careful not to place it into your site's root directory (or your WP install directory). There should be .htaccess files in both ("both" - in case your root directory and your wp install directory is not the same - probably the same though) and they contain important lines for your wp setup. If you override those files, your wp site might not work at all but in the least you get it deindexed.
Published in Blog
Friday, 23 February 2018 10:51

Using the WordPress wp_tag_cloud() Function

We all know that tags are a vital part of WordPress taxonomies, which are a way of grouping things together. Tags are created on the fly while creating posts and help us to locate similar posts linked by particular tags. Generally in a WordPress blog, different tags are grouped inside a tag cloud, and the size of each tag determines the frequency of its assignments to posts. Here we shall look into the correct usage of the wp_tag_cloud() function, which is responsible for all these tag clouds.

This is the main built-in function to display the tags associated with your recent posts, within the tag cloud.

The WordPress Codex wp_tag_cloud() page has a clear explanation of all the parameters of this function, but still let's quickly discuss the important ones.

  • 'smallest' – This parameter is of type integer and specifies the minimum text size of the tag in the cloud
  • 'largest' – This parameter is of type integer and specifies the maximum text size of the tag in the cloud
  • 'number' – This parameter specifies the total number of tags to be displayed in the cloud. You can specify it as '0' if you want all of them to be displayed
  • 'format' – This parameter specifies the format of the cloud display. It can be any of 'flat', 'list', or 'array'
  • 'separator' – This parameter specifies the separator within the tags in the cloud
  • 'topic_count_text_callback' – This parameter shows the number of posts associated with each Tag through a tooltip
  • 'taxonomy' – This parameter specifies the type of WordPress taxonomy which can be used within the tag cloud. Here the default is the 'post_tags' but you can use a custom taxonomy as well

These parameters play a key role in customizing the tag cloud.

WordPress has a default Tag Cloud widget which can be placed in the appropriate area of the page. But without using a widget you can use the wp_tag_cloud() function to display and customize the tag cloud in your blog. You can specify the parameters in a number of ways.

Parameters separated by '&' in one simple inline string.

Parameter specification in array format.

Specifying only selected parameters, the rest are kept as default.

Return the tag cloud as an array without displaying it in the blog. This result can be used later within the PHP code.

Create a function in your functions.php file and return the wp_tag_cloud() function. Once it is defined, you can call the function anywhere within your blog.

Now let us open our sidebar.php and call the function to display the tag cloud.

Let's add some CSS styling in our style.css file to make the tag cloud look more professional.

Now it looks like this:

Similarly using the same in the footer.php of our theme.

You can make it more beautiful by adding your custom CSS styles.

By adding different parameters within the wp_tag_cloud() function in the functions.php file we can customize our tag cloud. For example, if you like to include both your tags and categories into the tag cloud or rather the taxonomy cloud then the function can be written as:

Sometimes you do not like to keep the tag cloud in your sidebar or footer and creating a separate page for it keeps your blog clean. You can do so using the following method.

At first create a custom page template in your theme folder with the wp_tag_cloud() function. Here we have named the file tagcloud.php.

Now log in to your WordPress admin and go to Pages -> Add New. Put a good title for the page and then under the Page Attributes section choose the Template as Tag Cloud and then click on Update. That's it; your tag cloud page is ready. You can style the page with your own CSS styles.

Sometimes we want our users to select tags from a scrollable box in our sidebar. To accomplish this we have to create a function in our functions.php file.

In the above function we have considered the array format of the wp_tag_cloud() function, along with that the font size has been kept the same and the list has been ordered by name in ascending order.

Now open your sidebar.php and call this function.

Let us style it with some CSS.

Finally it looks like:

Thanks for reading and please feel free to suggest some more uses of this very useful wp_tag_cloud() function.

Published in Blog
Wednesday, 21 February 2018 07:11

If statement for custom post types

Here's a handy conditional snippet to target specific archive or single pages from a custom post type.

Published in Blog
Tuesday, 23 January 2018 05:05

Wordpress CSV plugin roundup

Recently I needed a wordpress plugin that allowed me to import a CSV file and store the data into a SQL table. Not knowing any particular plugins I decided to to download, install and test a whole bunch of them - and the results, whilst not always providing a solution to my original problem where still very interesting.

Import CSV files


A very simple plugin that efficiently imports data from a CSV file and matches it against a variety of post/page related fields. I can see that this plugin would be extremely helpfull for creating pages or posts from a spreadsheet of data. I can already forsee a potential use for this plugin in an upcoming project where I need to migrate much content from static HTML website into a wordpress site.



Another great content importer that matches the CSV data to a variety of wordpess fields. This plugin is very simple to use, and has a number of advanced features in the free version such as the ability to not only map the content to a wordpress post or page, but also a user, taxonomy, or custom post type. The premium version of this plugin allows automated scheduled importing.



TablePress allows you to easily create and manage beautiful tables. You can embed the tables into posts, pages, or text widgets with a simple Shortcode. Table data can be edited in a speadsheet-like interface, so no coding is necessary. Tables can contain any type of data, even formulas that will be evaluated. An additional JavaScript library adds features like sorting, pagination, filtering, and more for site visitors. Tables can be imported and exported from/to Excel, CSV, HTML, and JSON files.



Need to insert a table into your page or post? WordPress Tables plugin will take your data in CSV/JSON format or directly from MySQL table and create an interactive data table. With WPTables plugin, you can easily create and manage your tables from the WordPress administration. Simply insert a shortcode into your page, article or post, and you are ready to go. That’s it! Enjoy your new table.



WP CSV to Database plugin allows you to insert CSV file content into WordPress database. You can selectively insert data into a particular database table. You can also export any WordPress database table content to a CSV file using this plugin. Useful when you want to bulk upload data from your CSV file (example: product details) to the WordPress database in one go. Bulk data import from CSV (Microsoft Excel) file. Bulk data export from your database to CSV file

Published in Blog
Page 1 of 4