Support

Account

Forum Replies Created

  • It seems to be the way to go, except for that I need to change the function for each instance of adding the code.

    So changing:
    my_acf_settings_path

    To:
    my_acf_accommodation_settings_path
    my_acf_products_settings_path
    my_acf_events_settings_path
    etc.

    Please let me know if I’m on the right track, thank you!

  • I realise that my problem in saving the slug, is that it causes an infinite loop.

    Instead, I added

    $my_post['post_name'] = '';

    to

     $my_post = array();
        $my_post['ID'] = $post_id;
        $my_post['post_name'] = '';
        $posttypes = array( 'page', 'post', 'portfolio' );
        $currentposttype = get_post_type($post_id);
  • Hi, Im using the above, and it works for me,
    What I added, in order to make the post slug work is this:
    While it works, I am not sure whether it is the best approach, seems to make the saving of a post very slow.

    add_action('save_post', 'set_slug');
    
    function set_slug($post_id){
        $new_slug = get_post_meta($post_id,'custom-slug', true);    
        $post_args = array(
            'ID' => $post_id,
            'post_name' => $new_slug,
        );
    
        wp_update_post($post_args);
    }
Viewing 3 posts - 1 through 3 (of 3 total)