Saturday, 16 November 2019 02:36

Echo custom taxonomy values


<?php
$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
    
<?php
$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:
https://premium.wpmudev.org/blog/git-for-wordpress-development/

The first solution detailed in the above blog post is quick linked here:
https://premium.wpmudev.org/blog/improve-wordpress-development-workflow-local-server/

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
<?php
$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">

<?php

// 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(); ?>

<?php
$counter++;
?>

<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'); ?>
</button>
</h2>
</div>

<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'); ?>
</div>
</div>
</div>

<?php endwhile;

else :

// no rows found

endif;

?>

</div>
</div>
</section>



Published in Blog
Sunday, 16 September 2018 00:42

Dynamic responsive alternating grid squares

Uses:

  • 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.


<?php
$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
Page 1 of 4