<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters