• Resolved mnhfile

    (@mnhfile)


    I want to add this(below) custom code to my function.php file and i don’t know how to add this whether i add this code as it is or add php tag after or before it…like (<?php(—code—-)?>)

    // stop wp removing div tags
    function ikreativ_tinymce_fix( $init )
    {
        // html elements being stripped
        $init['extended_valid_elements'] = 'div[*],article[*]';
    
        // don't remove line breaks
        $init['remove_linebreaks'] = false; 
    
        // convert newline characters to BR
        $init['convert_newlines_to_brs'] = true; 
    
        // don't remove redundant BR
        $init['remove_redundant_brs'] = false;
    
        // pass back to wordpress
        return $init;
    }
    add_filter('tiny_mce_before_init', 'ikreativ_tinymce_fix');
Viewing 5 replies - 1 through 5 (of 5 total)
  • navigate to

    /wp-content/themes/your-theme-directory/functions.php

    and add the code at the end of the file there. you do not need the PHP tags at all. The functions file already has an opening php tag <?php in it.

    Thread Starter mnhfile

    (@mnhfile)

    what happen if I add <?php before and ?> at the end of the code… Is the code get wronged by doing this…

    if there is already an opening php tag at the begining of the file, you do not need to add a new tag.

    It is not recommended to use the closing php tag in the function file. Why do you try and see what happened..

    paste

    // stop wp removing div tags
    function ikreativ_tinymce_fix( $init )
    {
        // html elements being stripped
        $init['extended_valid_elements'] = 'div[*],article[*]';
    
        // don't remove line breaks
        $init['remove_linebreaks'] = false; 
    
        // convert newline characters to BR
        $init['convert_newlines_to_brs'] = true; 
    
        // don't remove redundant BR
        $init['remove_redundant_brs'] = false;
    
        // pass back to wordpress
        return $init;
    }
    add_filter('tiny_mce_before_init', 'ikreativ_tinymce_fix');

    at the end of the functions.php file of your theme (not WordPress core functions.php).

    Thread Starter mnhfile

    (@mnhfile)

    Thank you justin greer

    Your welcome.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘How to add code in PHP file… function.php’ is closed to new replies.