• Hi – I created a child theme to add some php code to modify the Timeline Express plugin. I obtained the code from a Timeline Express help article to add a custom metabox and excerpt. Though I am somewhat familiar with HTML and CSS, I have never coded php before, so I can’t figure out what’s going wrong.

    The error became apparent when I got a blank log-in screen for wp-admin after creating the child theme. I poked around on support, discovered that problems with the child theme might be the issue and when I renamed my child theme by adding “temp” to the name, I was able to get the log in page and log in sans child theme.

    All well and good. But I want to use that child theme and after going round and round (and discovering 2 easy to spot syntax errors) I don’t know where the error in my php file is. Note: I have not added anything to my child theme css file yet – and I could probably debug that one myself.

    Could someone look over this php code (entirety of my child functions.php file) and tell me what I have done wrong? Thank you!

    The webpage this is for is at https://tannarayoung.com/new_site/ – it’s in development so please excuse the mess

    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    //below is to make links in timeline express
    /**
     * Timeline Express Add Custom Metabox
     * @param array $options Array of options for Timeline Express.
     */
    function define_custom_excerpt_metabox( $options ) {
        $announcement_custom_metabox = new_cmb2_box( array(
           'id' => 'custom_meta',
           'title' => __( 'Announcement Custom Excerpt', 'text-domain' ),
           'object_types' => array( 'te_announcements' ), // Post type
           'context' => 'advanced',
           'priority' => 'high',
           'show_names' => true, // Show field names on the left
        ) );
        // Container class
        $announcement_custom_metabox->add_field( array(
           'name' => __( 'Custom Excerpt', 'text-domain' ),
           'desc' => __( 'Enter the custom excerpt for this announcement in the field above.', 'text-domain' ),
           'id' => 'announcement_custom_excerpt',
           'type' => 'wysiwyg',
        ) );
    }
    add_action( 'timeline_express_metaboxes', 'define_custom_excerpt_metabox' );
    /**
     * Replace the default excerpt with our new custom excerpt
     * @param string $excerpt The original announcement excerpt.
     * @param integer $post_id The announcement post ID
     * @return string Return the new excerpt to use.
     */
    function replace_default_timeline_express_excerpt( $excerpt, $post_id ) {
        if ( timeline_express_get_custom_meta( $post_id, 'announcement_custom_excerpt', true ) ) {
           return apply_filters( 'the_content', get_post_meta( $post_id, 'announcement_custom_excerpt', true ) );
        } else {
           return $excerpt;
        }
    }
    add_filter( 'timeline_express_frontend_excerpt', 'replace_default_timeline_express_excerpt', 10, 2 );
    ?>
  • The topic ‘Error with PHP in Child Theme for Customizr’ is closed to new replies.