Thursday 1 January 2015

Allowing Your Visitors to Use Custom Post filters in Your Genesis Theme

Recently, I worked on an project and caught with an idea that I should share the case with. One of my clients wanted to use the custom post filter in his genesis theme to get rid of the “post” navigation since he was running a review website. And its justifiably so since it seems misleading to the audience because they aren't reading the actual posts but only reviews.


One of the best things about genesis framework is that its flexible enough to serve the diverse needs of its users at the time of custom WordPress development. Genesis comes with rich “filter” functions under the theme settings area, which lets you place the desirable text on the basis of the taxonomy (terms/categories/tags) at the end of the index page.

Altering this text within the genesis framework isn't an uphill battle. All you need is simply go to your latest Genesis (v1.6) wherein it's quite easy to filter older/newer and next/previous text in the post navigation.


Getting The Grips of Older / Newer Post Navigation Filter

One can easily perform modifications within the Genesis with the help pf the functions that reside under the Genesis Theme Settings. Exploring this particular area you'll assess Content Archives, where there is an option called Post Navigation Technique”, already set as Older/Newer. Here, the default output is “Older Posts and “Newer Posts”, and in order to filter this, the below mentioned code should be added to your child theme's functions.php file. Here I have changed the example as to read Older and Newer Reviews.

add_filter( 'genesis_older_link_text', 'gt_review_older_link_text' );
function gt_review_older_link_text() {
$olderlink = '« Older Reviews';
return $olderlink;
}
add_filter( 'genesis_newer_link_text', 'gt_review_newer_link_text' );
function gt_review_newer_link_text() {
$newerlink = 'Newer Reviews »';
return $newerlink;
}

Previous / Next Post Navigation Filter

This filter is just like the one we have just mentioned above except that it runs when the “Select Post Navigation Technique” which we find under the Content Archive is set to Previous/Next instead of Older/Newer. Here also we are getting a default output, which is “Previous Posts” and “Next Posts”. To filter this, we have to add the following code within the functions.php file which you can get inside the child theme. In this example too we have edited it to Read Previous and Next Reviews.

add_filter( 'genesis_prev_link_text', 'gt_review_prev_link_text' );
function gt_review_prev_link_text() {
$prevlink = '« Previous Reviews';
return $prevlink;
}
add_filter( 'genesis_next_link_text', 'gt_review_next_link_text' );
function gt_review_next_link_text() {
$nextlink = 'Next Reviews »';
return $nextlink;
}

And that's all you have to do. See pretty easy right?

Genesis is a great framework with some truly astonishing settings that help you create a website that helps you serve your client's needs efficiently. Its customization abilities are unique and they allow you give your website and its readers what is actually useful to them.

However, if you want to learn some more methods and ways to filter custom posts than you can rely upon some handy plugins like Beautiful Taxonomy Filters . The plugin can be described absolutely dynamic when it comes to add filtering to your custom post types archives based on taxonomies. The plugin is extremely useful to filter CPTs in the manner most effective.

To know more about this plugin, Beautiful Taxonomy Filters allows you alter rules to create pretty filter URLs by eliminating the need to use JavaScript. It helps you spruce up your custom posts type archives by allowing visitors filter posts on the basis of their terms or categories. The plugin does everything for you in the most seamless way. The plugin works automatically, without having any need to use JavaScript, and the best part is it is based on WordPress Plugin Boilerplate which allows you organize the codebase using the object-oriented approach.

The plugin is capable enough to handle and include as many as filters. However, if you have post type with varied taxonomies, you can better keep out those who aren't useful for filtering.

Some of the other highlighted features include:

  • Active filtering on any registered public custom post type.
  • Keep those taxonomies out you don't want your visitors to filter on
  • Comes complete with functional filter component which you can put in your theme.
  • Visitors can be presented with the information regarding their current active filtering.
  • Integrated with custom GET parameters.
  • Additional filters, settings, and actions to fine tune the filter module behavior.

The plugin provides a convenient and fast way of adding multiple taxonomies to filter custom post types archives. One can also easily extend its capabilities and actions to make it more compelling and versatile. I personally have tested this plugin and found it to be extremely great in the way it helped me to achieve my goals. So, you can also use it whenever the needs arise. It will not disappoint you for sure. Even if you are not confident about your skills you can better hire a WordPress developer, who will deploy his skills and knowledge to give you exactly what you have in your mind in an efficient manner. 

1 comment: