This topic has 1 reply, 2 voices, and was last updated 7 years by Abe.

  • Author
  • #157394
     alans77
    Participant

    Hi

    I get a blank page, when I add this code to my functions.php.

    The code is from WPML – this is my ticket – https://wpml.org/forums/topic/one-shop-page-for-all-languages/.

     

    add_action( 'wp_insert_post', 'my_duplicate_on_publishh' );
    function my_duplicate_on_publishh( $post_id ) {
           
        $post = get_post( $post_id );
            
        // don't save for autosave
        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
            return $post_id;
        }
        // dont save for revisions
        if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
            return $post_id;
        }
        //insert your custom post type here
        if($post->post_type == 'product'):
         
        // we need this to avoid recursion see add_action at the end
        remove_action( 'wp_insert_post', 'my_duplicate_on_publishh' );
         
            // make duplicates if the post being saved
            // #1. itself is not a duplicate of another or
            // #2. does not already have translations
         
            $is_translated = apply_filters( 'wpml_element_has_translations', '', $post_id, $post->post_type );
         
            if ( !$is_translated ) {
                do_action( 'wpml_admin_make_post_duplicates', $post_id );
            }
         
        // must hook again - see remove_action further up
        add_action( 'wp_insert_post', 'my_duplicate_on_publishh' );
        endif;
    }

     

     

    The code works with the deault theme – Twenty Seventeen, but not with Kleo.

     

    Thanks for your help – Alan

    #157441
     Abe
    Keymaster

    Hi, enable
    Please update the theme to latest version and the afferent plugins, you can check the plugin update status from wp-admin -> appearance -> install plugins.

    Please follow these steps to enable wp debug:

    •  Connect to your server by FTP
    • Look in root directory of your WordPress install and open wp-config.php
    • Search for define( ‘WP_DEBUG’, false ); and change FALSE value to TRUE
    COPY CODE
    define( 'WP_DEBUG', true );
    
    •   After this line add this:
    COPY CODE
    define( 'WP_DEBUG_LOG', true );
    

    WP_DEBUG_LOG is a companion to WP_DEBUG that causes all errors to also be saved to a debug.log log file inside the /wp-content/ directory. This is useful if you want to review all notices later or need to view notices generated off-screen (e.g. during an AJAX request or wp-cron run).

    Repeat the described actions and then check the debug.log file and let me know what error appears.

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

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

The forum ‘Bugs & Issues’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?