Title: Use custom function for post title template?
Last modified: August 21, 2016

---

# Use custom function for post title template?

 *  [ggg377](https://wordpress.org/support/users/ggg377/)
 * (@ggg377)
 * [13 years ago](https://wordpress.org/support/topic/use-custom-function-for-post-title-template/)
 * Hey everyone!
 * I currently have my WordPress SEO _Titles & Metas > Post Types > Posts > Title
   template_ settings as such: %%title%% · %%category%%.
 * However I need some more flexibility with listing the categories, as the WordPress
   SEO just stacks the categories next to each other without the option of excluding
   or re-ordering. Basically I’m looking to use code I’ve written on my own. Is 
   there an easy way to bypass WordPress SEO’s title template to inject my own code?
   Can I just paste my function in the field?
 * Thanks in advance!
 * [http://wordpress.org/extend/plugins/wordpress-seo/](http://wordpress.org/extend/plugins/wordpress-seo/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [ggg377](https://wordpress.org/support/users/ggg377/)
 * (@ggg377)
 * [13 years ago](https://wordpress.org/support/topic/use-custom-function-for-post-title-template/#post-3812881)
 * I figured I should get into **wordpress-seo/inc/wpseo-functions.php** and modify
   either of those lines: 1) **‘%%category%%’ => wpseo_get_terms( $r->ID, ‘category’),**
   2)
 *     ```
       function wpseo_get_terms( $id, $taxonomy, $return_single = false ) {
       	// If we're on a specific tag, category or taxonomy page, return that and bail.
       	if ( is_category() || is_tag() || is_tax() ) {
       		global $wp_query;
       		$term = $wp_query->get_queried_object();
       		return $term->name;
       	}
   
       	if ( empty( $id ) || empty( $taxonomy ) )
       		return '';
   
       	$output = '';
       	$terms  = get_the_terms( $id, $taxonomy );
       	if ( $terms ) {
       		foreach ( $terms as $term ) {
       			if ( $return_single )
       				return $term->name;
       			$output .= $term->name . ', ';
       		}
       		return rtrim( trim( $output ), ',' );
       	}
       	return '';
       }
       ```
   
 * Basically I’m thinking of modifying the code to allow the insertion of my custom
   php function somewhere in there.
 * Lets say the code is something like this:
 *     ```
       <?php
       foreach((get_the_category()) as $category) {
           if ($category->cat_name != 'hot') {
           echo '' . $category->name. '';
       }
       }
       ?>
       ```
   
 * Where would I insert this? Please help :'(

Viewing 1 replies (of 1 total)

The topic ‘Use custom function for post title template?’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [title template](https://wordpress.org/support/topic-tag/title-template/)

 * 1 reply
 * 1 participant
 * Last reply from: [ggg377](https://wordpress.org/support/users/ggg377/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/use-custom-function-for-post-title-template/#post-3812881)
 * Status: not resolved