Add taxonomy to page names – CMS Page Order

<?php
/**
* Add Taxonomy to Page Names - CMS Page Order
* Taxonomy: 'rotator-location'.
* Example of result: Page Name (taxonomy term)
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/add-taxonomy-to-page-names-cms-page-order
*
* @param string $post_title
* @param int $post_id
* @return string $post_title
*/
function be_cms_page_order_names( $post_title, $post_id ) {
$post_type = get_post_type( $post_id );
// Make sure we're on the CMS Page Order admin page
if( !( isset( $_GET['page'] ) && is_admin() && 'order-' . $post_type == $_GET['page'] ) )
return $post_title;
// Get Locations for post
$locations = wp_get_object_terms( $post_id, 'rotator-location' );
if( !empty( $locations ) && !is_wp_error( $locations ) ){
$first = true;
foreach( $locations as $location ) {
if( $first )
$post_title .= ' (' . $location->name . ')';
$first = false;
}
}
return $post_title;
}
add_filter( 'the_title', 'be_cms_page_order_names', 10, 2 );
view raw gistfile1.aw hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk