WordPress has_term Conditional Tag Shortcode

has_term checks if the current post has any of given terms. The first parameter can be an empty string. It expects a taxonomy slug/name as a second parameter and you can also pass a post ID or object as the third parameter.

It can be useful if you need to list a different message or apply a different css class to your post.

However, if you want to use this inside your content, it won’t work simply because you don’t run PHP code inside the WordPress content area.

has_term shortcode

This is where a simple shortcode can come a long way.

It’s a simple mapping of the has_term conditional tag to the [has-term] shortcode.
It gives you access to:

  • [has-term term="term-name" taxonomy="tax-name" value="true" id=""]
        List this if post has term-name
    [/has-term]
  • [has-term term="term-name" taxonomy="tax-name" value="false" id=""]
        List this if post doesn’t have term-name
    [/has-term]
<?php
/*
Plugin Name: WCK - Conditional Shortcode Based on has_term
Plugin URI: http://www.cozmoslabs.com
Description: Gives you access to the [has-term term="term-name" taxonomy="tax-name" value="true" id=""] List this if post has term-name [/has-term]  AND [has-term term="term-name" taxonomy="tax-name" value="false" id=""] List this if post doesn't have term-name [/has-term]
Author: Cristian Antohe
Version: 0.1
Author URI: http://www.cozmoslabs.com
*/
add_shortcode( 'has-term', 'wck_has_term_shortcode' );
function wck_has_term_shortcode( $atts, $content = false ){
	extract(
		shortcode_atts(	array( 'term' => '', 'taxonomy' => '', 'value' => true, 'id' => null,  ), $atts )
	);	
 
	if ( $value === 'true' ) $value = true;
	if ( $value === 'false' ) $value = false;
 
	if ( !$content || $term == '' || $taxonomy == '' ){
		return;
	}
 
	if ( has_term( $term, $taxonomy, $id ) && $value ){ 
		return $content;
	} elseif ( !has_term( $term, $taxonomy, $id ) && !$value ) {
		return $content;
	} else {
		return;
	}
}

You can also download it from here: Has Term Shortcode Plugin

Limitations

Currently there is no support for multiple term names to be passed inside term=”term-name” (similar to the actual has_term function), although that should be easy enough to implement in the plugin if you want to.

WordPress Creation Kit 2.0.6 and WordPress 3.9

Due to an overconfidence on our part regarding WordPress updates and compatibility issues with our plugins, we failed to test WordPress Creation Kit 2.0.5 with WordPress 3.9 before the official launch of WordPress 3.9.

We are sorry. We should have known better and we will make a habit out of testing our plugins with future versions of WordPress before they are released.

WYSIWYG Bug

Since WP 3.9 updated TinyMCE to the latest version (v.4) and our WYSIWYG editor was still using v.3, trying to initiate the two together causes JavaScript errors and the WordPress Editor and our own WYSIWYG Editor stopped working.

Also, due to the way WordPress loads TinyMCE v.4, we’re not able to use it any longer for our own WYSIWYG editor (the main reasons it took us a full day to issue the update). That is the reason why from version WCK 2.0.6 we’ve switched to CKEditor for the WCK WYSIWYG editor.

You can download the latest version of WordPress Creation Kit from:

  • wordpress.org
  • Your Account page
  • Or wait for an automatic update to be available for both the Free or the Pro, Hobbyist & Lifetime versions

Show Custom Fields in WordPress

Show Custom Fields in Theme

How to show custom fields in WordPress is one of the hardest thing to understand by non-technical users.

By default, WordPress gives you the possibility to add custom fields directly from the UI.

There are also a lot of plugins that let you add advanced custom fields like inputs, check-boxes, selects, etc.

However, almost all of those solutions fall short when it comes when you want to show custom fields in your template.

Show Custom Fields Using Code

The default way to show custom fields in WordPress would be to:

  1. Open the single.php or page.php template file from your theme (via FTP or locally)
  2. Find the_content function so you can list your custom fields after the actual content of the post or page
  3. Use the get_post_meta function to list custom fields

It doesn’t sound to complicated, but you’ve lost a non-technical user at opening single.php

This is how your page.php could look if you wanted to show two custom fields, book title and book ISBN code.

< ?php
/**
 * The template for displaying all pages
 *
 * This is the template that displays all pages by default.
 * @subpackage Twenty_Thirteen
 */
 
get_header(); ?>
 
	<div id="primary" class="content-area">
		<div id="content" class="site-content" role="main">
 
			< ?php /* The loop */ ?>
			< ?php while ( have_posts() ) : the_post(); ?>
 
				<article id="post-<?php the_ID(); ?>" < ?php post_class(); ?>>
					<header class="entry-header">
						<h1 class="entry-title">< ?php the_title(); ?></h1>
					</header><!-- .entry-header -->
 
					<div class="entry-content">
						< ?php the_content(); ?>
 
<!-- Let's show our custom fields here -->						
 
< ?php 
 
	$my_book_title = get_post_meta( get_the_ID(), 'book_title', true);
	$my_book_isbn = get_post_meta( get_the_ID(), 'book_isbn', true);
 
	if( ! empty( $my_book_title ) ) {
		echo '<h3>Book Title: ' . $my_book_title . '<h3>';
		echo '<p>ISBN: ' . $my_book_isbn . '</p>';
	}
 
?>
 
<!-- End showing our custom fields here -->						
						< ?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
					</h3></div><!-- .entry-content -->
 
					<footer class="entry-meta">
						< ?php edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '' ); ?>
					</footer><!-- .entry-meta -->
				</article><!-- #post -->
 
				< ?php comments_template(); ?>
			< ?php endwhile; ?>
 
		</div><!-- #content -->
	</div><!-- #primary -->
 
< ?php get_sidebar(); ?>
< ?php get_footer(); ?>

It’s no rocket science and really simple to pull off.

The problem starts when you try to do more complicated stuff, like groups of custom fields (metaboxes), repeaters fields and groups, connect posts using custom fields.

Show custom fields using Swift Templates without code

Listing your custom fields in WordPress is one of the simplest way to transform your website from static pages to a proper CMS. You can use it for:

  • Adding extra information on your posts and pages
  • Showcasing your team
  • Listing testimonials
  • Simple property listing
  • Custom product pages
  • Custom landing pages
  • Listing company services
  • And pretty much anything that might require some extra information

It’s possible to create all of the above without being a developer in three steps.

Read more

Post to Post Relationships with WCK 2.0.4

A new version of WordPress Creation Kit is now available: 2.0.4 with Post to Post Relationships

post to post relationships

WordPress Post to Post Relationships

In WordPress post types are often in a relationship of some sort. For example, you might want to relate a soccer player to a team. You could do it with taxonomies, but it can become cumbersome and it won’t really do what you wanted it to do.

I wanted to use a post to post relationship in my project using other plugins, but I got really stuck when I tried to integrate those in my theme! I’m really not a programmer.

Truth is, post to post relationship plugins have been around for quite some time. The CPT Select field in WCK quite some time ago, but to really make use of it you had to open up your editor and start getting really good at WP_Query.

Read more

WordPress 3.8 – The Best Redesign Since Ever?

WordPress 3.8 is just around the corner and I can honestly say it’s THE most exciting release since ever! With the WordPress 3.8 RC2 available for download, we’re only days away from the excellently polished WordPress 3.8 UI.

Much more than just a new skin

You can see by the title of this post that I’m quite excited about this release. The old design has been around since 2.7 with only minor improvements across the board (was back in 11’th of December 2008 when 2.7 was launched, 5 years ago!). While the new, WordPress 3.8 UI, keeps most of the elements in the same place, it’s clearly the biggest thing to happen visually in the last 5 years.

WordPress 3.8 UI is stunning to look at and work with, but it also represents the best responsive/mobile implementation we’ve seen for the WordPress backend so far:

  • the top and sidebar menus have been re-envisioned for small resolutions
  • the sidemenu is now hidden by default and can be much more easily extended on small devices.
  • the Add New Post works wonderful for resolutions under 600px
  • every button and link is just a little bit larger, so you can tap them even if you have big thumbs
  • comes with its own flat vector icon font for the admin UI, called dashicons
  • it’s not just a refined implementation of what was before, it was created with devices of all sizes in mind

mobile

Read more

WordPress Creation Kit Video

WordPress Creation Kit helps you develop intuitive WordPress sites, easily manageable by your clients, in half the time and without writing a single line of PHP code.

However, this is somewhat hard to visualize, so to that end we created a WordPress Creation Kit video explaining:

  • what is WCK
  • what you can do with it, in a tutorial like structure.
  • walking through almost all of the modules inside WCK

I tried to keep it as short as possible so consider this as a basic introduction.

Also we have MORE videos planned in the future, so if you have suggestions or thoughts you want to share, now is the time!

Swift Templates – a straight forward alternative to WordPress templates hell

I’m not a programmer… I do know some basic html and css, but I was nervous about messing with any of the templates in fear of making a bigger mess than where I started.

That’s a quote from one of our customers. We hear this quite a lot, not everybody is a developer. Most WordPress users just want something simple to understand and quick to get started with.

So you can’t help but wonder if the WordPress templates system couldn’t have been designed differently?

When you’re starting out it’s just painful. You would do anything BUT custom code your WordPress templates:

  • research 10+ plugins HOPING they can solve your problem
  • start using a lot of shortcodes inside the content area
  • consider reading that 5 parts HUGE article explaining how to custom code your own WordPress templates

You might even say, “Well, now that’s something you need to learn. Here’s the X or Y awesome tutorials on the matter!”

But the truth is, WordPress templates ARE complicated for a large number of WordPress users.
You’ll bump into:

As for learning about the WordPress templates system, all those articles and tutorials are just copying mechanisms. Just search Google for “develop WordPress theme” and you’ll find OVER 8 MILLION results!

Why does there have to be so many articles teaching you this? Should WordPress Templates really be so hard to understand?

Now imagine a system that will let you:

  • create listings of all your custom post types
  • single page templates that take into account your custom fields and metaboxes previously defined with WCK
  • without writing PHP and messing with any of the templates
  • no more playing around with a ton of shortcodes and plugins to list a simple custom post type or extra field.

Swift Templates beta for WordPress Creation Kit

swift_code
Swift Templates helps you build front-end templates directly from the WordPress admin UI, without writing a single line of PHP code.

It turns a time consuming and error prone process that was previously only accessible to developers into a straight forward UI that with a little bit of HTML and CSS allows you to:

  • create archive listings for your custom post types including pages or posts
  • modify the single cpt page template to include ALL your custom fields and metaboxes
  • overwrite the default listing for your all single CPT’s with the one defined above
  • overwrite the default content with a template that gives you access to your custom fields and metaboxes

How does it work?

There are two (2) main cases where you can use Swift Templates.

1. Archive listing of CPT’s

swift-templates

Useful for:

  • normal archive pages with your own design (not theme dependent). Just create your templates, create a normal page that will contain the archive and add the swift-template shortcode
  • simple listings of posts or custom post types in any landing page on your site
  • (using the swift-template shortcode). Create your templates, setup the arguments and put the swift-template shortcode

Quickly create templates for posts, pages or custom post types that can include default WordPress information (the title, content, thumbnail, etc.) or Custom Fields previously defined with WordPress Creation Kit.

You can create read-more links to point to a Swift dynamically generated single template OR the default permalink.

swift-templates-code

Also, another really useful function is the possibility to overwrite the default content on that post with the single template, thus applying that template for ALL default single listings of your custom post type.

2. Single page listing of CPT’s

swift_single_team_page

Useful for creating one off templates for pages or single posts / custom posts.

Let’s say you have a team page, with some extra fields for name, avatar and description. You can now overwrite the default page template with one that supports your extra fields available for that page only.

Why Beta?

In order to get this out to our customers we had to launch without some features that will make building WordPress custom templates even more … swift

Coming soon:

  • new pre-processed swift tags that will list ALL fields in a metabox with a default HTML and CSS – you’ll be able to make perfectly styled templates in under a minute.
  • swift tags support for custom taxonomies
  • search tag for archive templates (have a CPT called books.. this will let you search inside them)

Got you interested? Here’s how to get it

As of today, Swift Templates is available with the latest version of WordPress Creation Kit PRO.

For all previous WCK PRO and Lifetime clients, Swift Templates will be available via automatic updates or the account page.

What about WordPress templates?

Swift templates are NOT a 1 to 1 replacement to WordPress templates. That would be stupid! WordPress templates are complicated for a reason, there are a LOT of things to display in WordPress and that flexibility comes with a lot of complexity.

However, we’re hoping for Swift Templates in combination with the rest of WordPress Creation Kit to take you 80% there in 80% of cases. If we can achieve that, I’ll be one happy developer!

WCK 1.1.0 is now alive and kicking!

Want to build a bullet proof, content adding interface for your clients, dead simple to use?

wck_custom_fields

WordPress Creation Kit helps YOU to improve the usability of the sited you build, making them manageable by your clients. Your very own repeater custom fields and groups, custom post type and taxonomy creator with front-end posting.

On WCK powered websites, clients will be able to easily enter their content without getting confused by shortcodes, html and who knows what else, because the UI will look and feel like it’s part of WordPress.

What’s new?

  • Options Page Creator – you to create new admin menu items called “Client Site Options” which can hold advanced custom field groups (just like any other edit page).
  • More extra-field types: Date, User Select, Country Select.
  • Automatic Updates via the WordPress Plugins interface.
  • Quite a few bugfixes and small improvements.
  • Multiple versions at different pricing points. (We have a Pro and Hobbyist version available now)

plans_pricing

Give Clients the Power to Self-Manage and Update Their WordPress Sites

UPDATE: WordPress Creation Kit 1.1.0 is now available for download

To developers, the WordPress admin interface is really simple and intuitive, particularly considering the amount of trouble we go through to make things behave like they should.

I found out a lot of clients that were excited about having their own self-powered CMS, freaked out when trying to change a piece of content or simply weren’t using it at all. It still wasn’t easy or intuitive enough.

Three things that make it hard for non-technical clients to update their site

  • using HTML with different classes in the content editor. Sooner or later they are just going to forget a closing tag, break the site and that means an email or phone-call when you were in the middle of a really cool project and didn’t want to be interrupted.
  • using various plugins with settings with settings all over the place. They’re gona forget to change something and that’s coming back to you.
  • shortcodes – I know what you’re thinking, they are actually useful, but not if they forget the shortcode name or what parameters to use. Also, shortcodes get intertwined with content in the editor and that’s like using HTML, only a little bit easier.

Now imagine having a single place where your client can edit exactly what he needs: a couple of testimonials, update their logo or favicon, changing the copyright footer text, managing the slideshow on the homepage or give them some textareas where to insert their ads.

Welcome Options Page Creator – a new feature coming soon in WCK

options_page

The Options Page Creator Allows you to create a new menu item called “Client Site Options” which can hold advanced custom field groups (just like any other edit page). You can register multiple options pages with multiple meta-boxes and repeater fields.

Perfect for:

  • Theme Settings
  • Mini plugins that need an UI
  • Advertising zones
  • Small content pieces that don’t deserve a Custom Post Type just for them (mini-testimonials, widget like zones, etc.)

A new WordPress Creation Kit is coming June 13*

Building a bullet proof, content adding interface for your clients will get a lot easier.

WordPress Creation Kit helps YOU to improve the usability of the sited you build, making them manageable by your clients. Your very own repeater custom fields and groups, custom post type and taxonomy creator with front-end posting.

  • Custom Post Type Creator
  • Custom Fields Creator
  • Custom Taxonomy Creator
  • Front-End Posting
  • Options Page Creator

Hop on the list if you want first dibs and some more freebies from the launch day:



WordPress Email Confirmation for New Users

WordPress Email Confirmation for new users has been around in Profile Builder for quite some time, however something was missing from it.

What do I do if the confirmation email doesn’t send? Is there a way to force activate it?

Since new users that didn’t approve their emails are stored in the wp_signups database table, they don’t appear in All Users section. That’s how WordPress Email Confirmation works.

That turns into a problem when:

  • the user deletes the WordPress confirmation email before activating his account
  • the confirmation email end up in the spam folder
  • the email doesn’t get sent at all due to a server error

When the above happens, there are three problems that appear:

  • the user can’t approve his account
  • the user can’t try to register again with the same email or user name (since WordPress is still waiting for the previous account to approve his registration)
  • the admin can only delete the un-confirmed email from the database and can’t manually approve the account

Imagine having the possibility to manually approve users or delete fake accounts from wp_signups table

WordPress Email Confirmation

Starting with version 1.3.4 of Profile Builder (Pro and Hobbyist versions), the WordPress Email Confirmation just got better by giving you the possibility, as an admin, to manually approve or delete users that haven’t confirmed their email addresses directly from the WordPress backend.

To do so, just go to Users -> All Users and click the “Users with Unconfirmed Email Address” link. That’s it folks!