emakundi

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: Customizing Campaigns and Slugs #23900
    emakundi
    Member

    Amazing!!! Works like a charm, thank you so much!

    in reply to: Customizing Campaigns and Slugs #23892
    emakundi
    Member

    Hi meteorite,

    I managed to change the slug in my child theme by inserting this in my child theme’s functions.php file:

    add_action('init', 'change_campaign_slug', 100);
    
    function change_campaign_slug() {
    	$args = get_post_type_object('campaign');
    	$args->rewrite['slug'] = 'entrepreneur';
    	register_post_type($args->name, $args);
    }
    
    function my_rewrite_flush() {
        change_campaign_slug();
        flush_rewrite_rules();
    }
    
    register_activation_hook( __FILE__, 'my_rewrite_flush' );

    I visited Settings -> Permalinks and save the settings and the slug was updated.

    However, I am also trying to change the campaign category slug. I tried the following code in my child theme’s functions.php file:

    add_action('init', 'change_campaign_category_slug');
    
    function change_campaign_category_slug() {
    	$taxonomy = get_object_taxonomies('campaign', 'names');
    	$taxononmy->rewrite['slug'] = 'entrepreneur_category';
    	register_taxonomy($taxonomy->name, $taxonomy);
    }
    
    function my_rewrite_flush_2() {
        change_campaign_category_slug();
        flush_rewrite_rules();
    }
    
    register_activation_hook( __FILE__, 'my_rewrite_flush_2' );

    but the ‘campaign_category’ does not change to ‘entrepreneur_category’. Any ideas on how to rewrite post object taxonomies?

    Thank you!

    in reply to: Customizing Campaigns and Slugs #23868
    emakundi
    Member

    Hello again Pheonix,

    I think my issue has something to do with “flushing rewrite rules” but I am not sure how to go about it.

    https://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation

    I tried including the code snippet for plugin activation:

    function my_rewrite_flush() {
        lm_register_campaign_post_type();
    
        flush_rewrite_rules();
    }
    
    register_activation_hook( __FILE__, 'my_rewrite_flush' );

    after this snippet of code in register-post-types.php:

    if (!function_exists('lm_register_campaign_post_type')) {
    ...
    }

    but it is not working.

    Do you have any idea how to go about this?

    Thank you!

    in reply to: Customizing Campaigns and Slugs #23864
    emakundi
    Member

    Hi Phoenix,

    Thank you for you reply. I have modified the lines you mentioned and added this code to my functions.php file in my child theme:

    $register_post_types_path = get_stylesheet_directory() . '/framework/plugins/livemesh-tools/includes/';
    include_once($register_pot_types_path . 'register-post-types.php');

    I visited Settings -> Permalinks after I FTPed the register-post-types.php file but the slugs did not updated. Do I need to change something in Settings -> Permalinks?

    Is there anything else I should change in the register-post-types.php file to change the slugs?

    Thanks again!!

Viewing 4 posts - 1 through 4 (of 4 total)