Thursday, 21 May 2020 12:16

Create a loop for custom post types


// Define custom query parameters
$custom_query_args = array(
/* Parameters go here */
'posts_per_page' => 12,
'post_type' => 'video_production',

// Get current page and append to custom query parameters array
$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

// Instantiate custom query
$custom_query = new WP_Query( $custom_query_args );

// Pagination fix
$temp_query = $wp_query;
$wp_query = NULL;
$wp_query = $custom_query;

// Output custom query loop
if ( $custom_query->have_posts() ) :
while ( $custom_query->have_posts() ) :
$custom_query->the_post(); ?>

Do stuff here

// Reset postdata

// Custom query loop pagination
previous_posts_link( 'Older Posts' );
next_posts_link( 'Newer Posts', $custom_query->max_num_pages );

// Reset main query object
$wp_query = NULL;
$wp_query = $temp_query;

Published in Blog

Place this in your theme’s functions.php file.

Move Yoast to the Bottom
function yoasttobottom() {
return 'low';
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');

Published in Blog
Saturday, 16 November 2019 02:36

Echo custom taxonomy values

$terms = get_the_terms( get_the_ID(), 'bake-lovers-categories' );
if ($terms) {
foreach($terms as $term) {
echo '<span class="tag">'.$term->name . ' '.'</span>';

Published in Blog
$aust1 = types_render_field("available-in-australia", array("option"=>0));
if ($aust1) {
echo 'woolies';
$aust2 = types_render_field("available-in-australia", array("option"=>1));
if ($aust2) {
echo 'coles';
$aust3 = types_render_field("available-in-australia", array("option"=>2));
if ($aust3) {
echo 'other';

Published in Blog

This is happening because the parent theme is calling in styles.css using enque.

Disable it by adding the following into the child themes functions file:

/* -- Removes the parent theme stylesheet,
to stop it being called twioce (Foundation CSS was being called after style.css)
-- */
function PREFIX_remove_scripts() {
wp_dequeue_style( 'screen' );
wp_deregister_style( 'screen' );

wp_dequeue_script( 'site' );
wp_deregister_script( 'site' );

// Now register your styles and scripts here
add_action( 'wp_enqueue_scripts', 'PREFIX_remove_scripts', 20 );
/* -- Removes the parent theme stylesheet END -- */

Published in Blog
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
Page 1 of 4