Disable Gutenberg for specific post types

add_filter('use_block_editor_for_post_type', 'prefix_disable_gutenberg', 10, 2);
function prefix_disable_gutenberg($current_status, $post_type) {
if ( ($post_type === 'post') || ($post_type === 'event') ) return false;
return $current_status;

How to remove the custom color picker from Gutenberg

function prefix_gutenberg_disable_all_colors() {
add_theme_support( 'editor-color-palette' );
add_theme_support( 'disable-custom-colors' );
add_action( 'after_setup_theme', 'prefix_gutenberg_disable_all_colors' );

WordPress: Wrap the published day, month, and year in span tags

Here is a quick and easy way to wrap the individual elements of your WordPress template’s published date output in tags:

<?php the_time('F <\s\p\a\n>jS</\s\p\a\n>, Y') ?>

Note: the key is to escape the each letter of the tag declaration with a back slash.

WordPress Tricks: How to create a WYSIWYG page template for an archive page

Recently, I was working on a WordPress site and needed the ability to have editable page content at the top of the archive page for a custom post type.

It took me a bit to figure out how to accomplish it but once I did, I am happy to report the solution was quite simple!

First, clone whichever page template in your theme that you want to use as the base template for your archive page. For example, let’s say you clone page.php and name your new file template-customposttype.php.

Make sure to change or add the template name at the very top of your cloned file:

/* Template Name: Custom Post Type Landing Page */

Now, under the portion of the template which calls in the page content, let’s add a query for the custom post type we want to display on this page:

<?php query_posts(array('post_type' => 'customposttype')); ?>

Make sure you change ‘customposttype‘ to the actual name of the post type you want to display on this page!

Now, open your theme’s archive.php template file and copy the section between get_header() and get_footer(). Paste this into your template-customposttype.php file, just under the query_posts() statement.

Save your new template.

Now, in the WordPress dashboard, create a new page called My Custom Posts Archive Landing Page. In Page Attributes, make sure to select your new template (“Custom Post Type Landing Page”) to this page.

Add whatever content you want in the visual editor, then publish your new page and view it on your site.

You will now see your custom content at the top of the page and the list of blog posts for your custom post type underneath! Voila!

WordPress Tricks: A simple shortcode which will output the site title

Here is a very simple way to create a shortcode that will output your WordPress site’s title.

Copy and paste this snippet into your active theme’s functions.php file:

function site_title_shortcode() {
	 $blog_title = get_bloginfo('name');
	return $blog_title;
add_shortcode('site_title', 'site_title_shortcode');

Now you can easily output the current site title anywhere in your content using the shortcode [site_title]

WordPress Tricks: Allowing the use of shortcodes within custom shortcodes

I was recently working on a site where I needed to add custom shortcodes and also allow the use of shortcodes within my custom shortcodes and here is how I did it.

I started by adding the standard code for creating custom shortcodes to my functions.php file:

function my_custom_shortcode( $atts, $content = null ) {
    return '<div class="customText">'.$content .'</div>';
add_shortcode("customText", "my_custom_shortcode");

And then wrapped $content in the do_shortcode() function, like this:

function my_custom_shortcode( $atts, $content = null ) {
    return '<div class="customText">'. do_shortcode($content) .'</div>';
add_shortcode("customText", "my_custom_shortcode");

Now I am able to use standard WordPress shortcodes within my custom shortcode, like so:

[customText] This is my custom text with a shortcode.[button value="Read More..."] [/customText]

WooCommerce Tips: Customizing the Credit Card Image for the WooCommerce Paypal Pro Plugin

Here is the code I used in my theme’s functions.php file to customize the images displayed on the Checkout page on a website using the WooCommerce Paypal Pro plugin:

function custom_paypal_pro_icon() {
    return get_stylesheet_directory_uri().'/images/credit_card_logos_9.gif'; // use "get_stylesheet_directory_uri()" so the path works when child themes are active
add_filter( 'woocommerce_paypal_pro_icon', 'custom_paypal_pro_icon' );

I imagine you can use this snippet for other payment gateways as well, since I actually customized this code based off an article I found which explained how to change the default Paypal icon.

The tag that clarifies which payment gateway’s icon you are changing is: woocommerce_paypal_pro_icon

I found the correct tag to use for the Paypal Pro plugin in wp-content > plugins > woocommerce-gateway-paypal-pro > includes > class-wc-gateway-paypal-pro.php on line 16:

$this->icon = apply_filters('woocommerce_paypal_pro_icon', WP_PLUGIN_URL . "/" . plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/assets/images/cards.png' );

WordPress SimplePress Theme Customization: Adding custom thumbnails to home page slider

I recently worked on a project where I needed the ability to have the navigation thumbnails on the home page slider of the SimplePress WordPress theme to be customizable, not automatically generated off of the featured image as they are by default. Here are the steps I took to accomplish that:

First, install and activate the Multiple Post Thumbnails plugin.

Next, copy and paste this code into your theme’s functions file (be sure to create a child theme of the SimplePress theme before making these customizaations!):

if (class_exists('MultiPostThumbnails')) {
	new MultiPostThumbnails(array(
	'label' => 'Secondary Image',
	'id' => 'secondary-image',
	'post_type' => 'post'
 ) );

Third, open the “includes/featured.php” file of your child theme, and replace this code on lines 109-118:

	print_thumbnail( array(
	'thumbnail' 	=> $arr[$i]["thumb_small"],
	'use_timthumb' 	=> $arr[$i]["thumbnail"]["use_timthumb"],
	'alttext'		=> $arr[$i]["fulltitle"],
	'width'			=> (int) $width_small,
	'height'		=> (int) $height_small,
	'et_post_id'	=> $arr[$i]['post_id'],
) );

With this:

if (class_exists('MultiPostThumbnails')) {                              
      while ($t<1) {
          $image_name = 'secondary-image';
          if (MultiPostThumbnails::has_post_thumbnail('post', $image_name)) { 
              $image_id = MultiPostThumbnails::get_post_thumbnail_id( 'post', $image_name, $arr[$i]['post_id'] ); 
          if ($image_id == "") {
              $image_id = get_post_thumbnail_id( $arr[$i]['post_id'] ); 
              $image_attributes = wp_get_attachment_image_src( $image_id );  ?>
              <img src="<?php echo $image_attributes[0]; ?>" alt="<?php echo $arr[$i]["fulltitle"]; ?>" width="<?php echo $width_small; ?>" height="<?php echo $height_small; ?>">

And there you have it – now you have the ability to choose a secondary featured image for your posts which will be used for the navigation thumbnail in the home page slider when available, otherwise the thumbnail will default to the featured image as usual.

WordPress: How to Truncate the Length of Titles in Previous / Next Post Links

Here is the code I use to truncate the length of post titles in previous post / next post links on WordPress sites:

$prev_post = get_previous_post();
if($prev_post) {
   $prev_title = strip_tags(str_replace('"', '', $prev_post->post_title));
   $getlength = strlen($prev_title);
   $thelength = 25;
   echo '<a href="' . get_permalink($prev_post->ID) . '" title="' . $prev_title. '">&lsaquo;&nbsp;';
   echo substr($prev_title, 0, $thelength);
   if ($getlength > $thelength) echo "...";
   echo '</a>&nbsp;';

echo '&nbsp;|&nbsp;';

$next_post = get_next_post();
if($next_post) {
   $next_title = strip_tags(str_replace('"', '', $next_post->post_title));
   $getlength = strlen($next_title);
   $thelength = 25;
   echo '<a href="' . get_permalink($next_post->ID) . '" title="' . $next_title. '">';
   echo substr($next_title, 0, $thelength);
   if ($getlength > $thelength) echo "...";
   echo '</a>&nbsp;&rsaquo;';

The result looks something like this:

« This is the title of th… | This is the title of th… »

CiviCRM + WordPress + QuickBooks: Installing the Intuit Quickbooks Extension in your WordPress+CiviCRM installation

I have not found very clear instructions or support on how to download and install the QuickBooks extension for CiviCRM in my WordPress + CiviCRM installation so I am going to share the steps I took to accomplish this here, for future reference for myself as much as anyone 🙂

First, this is the extension that I used – https://github.com/NileemaJadhav/Intuit

Click the “Download” button on the right hand side of the page to download a zip file.

Once the zip file has been downloaded, expand the folder.

Inside the expanded folder, named Intuit-master, you will see another folder called org.civicrm.payment.intuitquickbooks. Upload this folder and its contents to your designated CiviCRM extensions directory.

Using your FTP client of choice, open the org.civicrm.payment.intuitquickbooks folder which you just uploaded, and move the file named IntuitQuickbooksIPN.php to this folder: <your website root>/wp-content/plugins/civicrm/civicrm/bin

Now log into your WordPress dashboard and click CiviCRM in the sidebar.

In the CiviCRM admin panel of your WordPress dashboard, navigate to Administer > System Settings > Manage Extensions. Once on this page, you will most likely have to click the “Refresh” button to see the Intuit extensions listed as available for installation, at least I did. After you’ve refreshed the list of extensions available for download, click the “Install” link next to the Intuit extensions to install it.

Once the extension has been installed, navigate to Administer > System Settings > Payment Processors. Click the button to add a new Payment Processor, and now in the dropdown list next to “Payment Processor Type“, you will see Intuit Quickbooks as an option.

Here is a tutorial with further information on getting your QuickBooks extensions configured – http://wiki.civicrm.org/confluence/display/CRM/Setting+up+Intuit+QuickBooks+Payment+Processor+for+CiviCRM

Hope this step-by-step tutorial saves someone the time I have spent trying to get this working 🙂