Do function.php of child theme has bug?
-
The contents written in function.php of the child theme is not reflected.
<?php /** * OnePress Child Theme Functions * */ /** * Enqueue child theme style */ add_action( 'wp_enqueue_scripts', 'onepress_child_enqueue_styles', 15 ); function onepress_child_enqueue_styles() { wp_enqueue_style( 'onepress-child-style', get_stylesheet_directory_uri() . '/style.css' ); } /** * Hook to add custom section after about section * * @see wp-content/themes/onepress/template-frontpage.php */ /* function add_my_custom_section(){ ?> <section id="my_section" class="my_section section-padding onepage-section"> <div class="container"> <div class="section-title-area"> <h5 class="section-subtitle"> My section subtitle</h5> <h2 class="section-title"> My section title</h2> </div> <div class="row"> <!-- Your section content here, you can use bootstrap 4 elements :) --> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p> </div> </div> </section> <?php } add_action( 'onepress_after_section_about', 'add_my_custom_section' ); */ //CSS追加 function add_wp_head (){ echo '<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">'; } add_action ('wp_head','add_wp_head',1); //Custom CSS Widget add_action('admin_menu', 'custom_css_hooks'); add_action('save_post', 'save_custom_css'); add_action('wp_head','insert_custom_css'); function custom_css_hooks() { add_meta_box('custom_css', '個別CSS', 'custom_css_input', 'post', 'normal', 'high'); add_meta_box('custom_css', '個別CSS', 'custom_css_input', 'page', 'normal', 'high'); } function custom_css_input() { global $post; echo '<input type="hidden" name="custom_css_noncename" id="custom_css_noncename" value="'.wp_create_nonce('custom-css').'" />'; echo '<textarea name="custom_css" id="custom_css" rows="5" cols="30" style="width:100%;">'.get_post_meta($post->ID,'_custom_css',true).'</textarea>'; } function save_custom_css($post_id) { if (!wp_verify_nonce($_POST['custom_css_noncename'], 'custom-css')) return $post_id; if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id; $custom_css = $_POST['custom_css']; update_post_meta($post_id, '_custom_css', $custom_css); } function insert_custom_css() { if (is_page() || is_single()) { if (have_posts()) : while (have_posts()) : the_post(); if (get_post_meta(get_the_ID(), '_custom_css', true) !='') { echo "<style type=\"text/css\" media=\"all\">\n".get_post_meta(get_the_ID(), '_custom_css', true)."\n</style>\n"; } endwhile; endif; rewind_posts(); } } //Custom JavaScript Widget add_action('admin_menu', 'custom_js_hooks'); add_action('save_post', 'save_custom_js'); add_action('wp_head','insert_custom_js'); function custom_js_hooks() { add_meta_box('custom_js', '個別JavaScript', 'custom_js_input', 'post', 'normal', 'high'); add_meta_box('custom_js', '個別JavaScript', 'custom_js_input', 'page', 'normal', 'high'); } function custom_js_input() { global $post; echo '<input type="hidden" name="custom_js_noncename" id="custom_js_noncename" value="'.wp_create_nonce('custom-js').'" />'; echo '<textarea name="custom_js" id="custom_js" rows="5" cols="30" style="width:100%;">'.get_post_meta($post->ID,'_custom_js',true).'</textarea>'; } function save_custom_js($post_id) { if (!wp_verify_nonce($_POST['custom_js_noncename'], 'custom-js')) return $post_id; if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id; $custom_js = $_POST['custom_js']; update_post_meta($post_id, '_custom_js', $custom_js); } function insert_custom_js() { if (is_page() || is_single()) { if (have_posts()) : while (have_posts()) : the_post(); if (get_post_meta(get_the_ID(), '_custom_js', true) !='') { echo "<script type=\"text/javascript\">\n".get_post_meta(get_the_ID(), '_custom_js', true)."\n</script>\n"; } endwhile; endif; rewind_posts(); } } //固定ページの改行無効 add_filter('the_content', 'wpautop_filter', 9); function wpautop_filter($content) { global $post; $remove_filter = false; $arr_types = array('page'); //自動整形を無効にする投稿タイプを記述 $post_type = get_post_type( $post->ID ); if (in_array($post_type, $arr_types)) $remove_filter = true; if ( $remove_filter ) { remove_filter('the_content', 'wpautop'); remove_filter('the_excerpt', 'wpautop'); } return $content; } //固定ページではビジュアルエディタを利用できないようにする function disable_visual_editor_in_page(){ global $typenow; if( $typenow == 'page' ){ add_filter('user_can_richedit', 'disable_visual_editor_filter'); } } function disable_visual_editor_filter(){ return false; } add_action( 'load-post.php', 'disable_visual_editor_in_page' ); add_action( 'load-post-new.php', 'disable_visual_editor_in_page' );I download and use the official child theme.
https://github.com/FameThemes/onepress-childHowever, it is not reflected even if it is described in function.php of child theme.
So I have no choice but to edit my parent theme.Is this a bug?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Do function.php of child theme has bug?’ is closed to new replies.
