• Resolved thecorkboard

    (@thecorkboard)


    Hello-

    I’d like to change the slug of my achievement types and their single-post templates. For the first, I’m a bit stumped. It seems that when you create an achievement type it is a new custom post type. So, I believe the way it would work is to tap into the rewrite arguments. Something like this:

    'rewrite'             => $rewrite,
    ....
    $rewrite = array(
    		'slug'                => 'tasks',
    		'with_front'          => false,

    But two things here: 1) I don’t know how badgeOS labels its new custom post types and 2) I don’t know how to tap into custom post types made by other plugins, only my own.

    As for the template, can I just create a single-tasks.php and it will load?

    Thanks for any help you can provide,
    ~Kyle~

    http://wordpress.org/extend/plugins/badgeos/

Viewing 1 replies (of 1 total)
  • Michael Beckwith

    (@tw2113)

    The BenchPresser

    You are correct, when you add a new achievement type, it’s its own custom post type. Essentially the devs created a custom post type whose posts are used to registered custom post types 🙂

    However, it does not appear that code has any filters in the function that does this registering. You can see it all in badgeos/includes/post-types.php. I may have to suggest some filters in the arguments, where applicable, or at least right before the actual registering.

    That said, it’s this line that grabs the value to be used for the rewrite slug. The problem is changing the value stored in the _badgeos_singular_name would affect a lot more than just the rewrite.

    $achievement_name_singular = get_post_meta( $achievement_type->ID, '_badgeos_singular_name', true );
    ...
    'rewrite' => array( 'slug' => sanitize_title( strtolower( $achievement_name_singular ) ) ),

    For the single template, via the WordPress template hierarchy, it’s always single-$posttypeslug.php. Same would be true with archives as well.

Viewing 1 replies (of 1 total)
  • The topic ‘Change Slug and Templates’ is closed to new replies.