0

I'm using a custom permalink structure for my posts, /blog/%postname%/. I installed a plugin which registers a custom post type, glossary. I don't want this post type to use the custom permalinks structure that standard posts are using. I believe that setting 'rewrite' => array('with_front' => false) when the post type is registered will accomplish this. The problem is that the post type is being registered by the plugin, so I can't modify the function directly within the plugin's code, at least not if I want an upgrade-proof fix. How can I add arguments to the array through my theme's functions.php file, rather than the plugin's code?

Here's the function the plugin uses to register the post type, in case that's helpful:

public function register_post_types(){
    register_post_type( 'glossary', array(
        'public'               => true,
        'menu_position'        => 105,
        'has_archive'          => true,
        'supports'             => array( 'title', 'editor', 'thumbnail', 'author', 'excerpt' ),
        'labels' => array(
            'name'               => __( 'Glossary Terms',                   'wp-glossary' ),
            'singular_name'      => __( 'Glossary Term',                    'wp-glossary' ),
            'add_new'            => __( 'Add New Term',                     'wp-glossary' ),
            'add_new_item'       => __( 'Add New Glossary Term',            'wp-glossary' ),
            'edit_item'          => __( 'Edit Glossary Term',               'wp-glossary' ),
            'new_item'           => __( 'Add New Glossary Term',            'wp-glossary' ),
            'view_item'          => __( 'View Glossary Term',               'wp-glossary' ),
            'search_items'       => __( 'Search Glossary Terms',            'wp-glossary' ),
            'not_found'          => __( 'No Glossary Terms found',          'wp-glossary' ),
            'not_found_in_trash' => __( 'No Glossary Terms found in trash', 'wp-glossary' )
        ),
        'register_meta_box_cb' => array( $this, 'meta_boxes' ),
        'rewrite'              => array( 'slug' => sanitize_title( _x( 'glossary', 'rewrite slug', 'wp-glossary' ) ) ),
    ) );

    add_filter( 'manage_glossary_posts_columns',       array($this, 'manage_glossary_posts_columns') );
    add_action( 'manage_glossary_posts_custom_column', array($this, 'manage_glossary_posts_custom_column'), 10, 2 );

    add_action( 'save_post',   array(&$this, 'save_glossary_post'), 10, 2 );
    add_filter( 'the_content', array(&$this, 'the_content'),        10, 2 );
} 
2

you can do this to modify the definition

$args = get_post_type_object("glossary");
$args->rewrite = array("with_front" => FALSE);
register_post_type($args->name, $args);

this has to be done after the call of "register_post_types()" of the plugin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.