Wordpress custom post title for custom post types

Discussion in 'PHP' started by TheLimeDesign, Aug 21, 2011.

  1. #1
    Hey guys,
    I'm building an application website and creating a versioning system for it. I have already created the custom post type and its working flawlessly. The unique identifier for the custom post type is 'app_ver'.
    Now, I want to create a custom title for this post type. That said, I just insert the version number in the post title and the output is generated in a string automatically. For example, I just insert "1.0.0" in the title and the output results as "Application version 1.0.0 released".

    I have this code that does this partially:

     <?php 
    add_filter('the_title', new_title);
    function new_title($title) { 
    return 'Application version '. $title. 'released';
    }
    ?>
    PHP:
    But the problem is, it changes the title of ALL titles including pages as well. I want it to only change the title of posts made under 'app_ver'.

    I've tried this too but its not working. Something is wrong in this code.

    
    add_filter('the_title', 'new_title');
    function new_title($title) {
    	global $post, $post_ID;
    	$title['app_ver'] = 'Application Name v'.$title;
    	return $title;
    }
    
    PHP:
    Help is greatly appreciated~
     
    TheLimeDesign, Aug 21, 2011 IP