• I am using the parent theme deCente and by default page comments are turned off. I found a comments.php file in the parent theme’s lib/framework folder. I want to remove the parent theme comments feature via my child theme and then put code in the child theme functions.php file to allow override the parent theme’s comment function’s TRUE/FALSE.

    What code is required in the child theme’s functions.php file to accomplish this?

    Here is the code that enables/disables the comments in parent theme:

    add_action( 'frameshift_post_content_after', 'frameshift_get_comments_template', 100 ); 
    
    function frameshift_get_comments_template() {
    
    	$args = array(
    		'comments_posts' 	   => true,
    		'comments_pages' 	   => false,
    		'comments_attachments' => false
    	);
    
    	$args = apply_filters( 'frameshift_get_comments_template_args', $args );
    
    	// Extract $args
    	extract( $args, EXTR_SKIP );
    
    	if ( is_single() && ! is_attachment() && $comments_posts == true ) {
    		comments_template( '', true );
    	} elseif ( is_page() && $comments_pages == true  && ! is_page_template( 'page-tpl-blog.php' ) ) {
    		comments_template( '', true );
    	} elseif ( is_attachment() && $comments_attachments == true ) {
    		comments_template( '', true );
    	}
    
    }

Viewing 8 replies - 1 through 8 (of 8 total)
  • Where did you download the theme from?

    Thread Starter Dishman

    (@dishman)

    I downloaded the free version from Themeshift. They also have a premium version. Here is the link: http://themeshift.com/theme/decente/.

    I can pick and choose what comments are active by changing true/false in the parent theme comments.php file and it works well. I just want this switch ability to be in the child theme so that it doesn’t go back to the default page comments = off when the deCente theme is updated.

    Thanks!

    Thread Starter Dishman

    (@dishman)

    I tried this approach in the child functions.php file, but it didn’t work. I don’t know much about coding to see where I went wrong.

    <?php
    function remove_parent_theme_features() {
        // remove Get Comments Template
        remove_action( 'frameshift_post_content_after', 'frameshift_get_comments_template' );
    
        add_action( 'frameshift_post_content_after', 'child_get_comments_template' );
    }
    
    function child_get_comments_template() {
        $child_args = array(
             'comments_posts'        => true,
            'comments_pages'        => true,
            'comments_attachments' => false
        );
    
        $child_args = apply_filters( 'child_get_comments_template_args', $child_args );    
    
        // Extract $child_args
        extract( $child_args, EXTR_SKIP );
    
        if ( is_single() && ! is_attachment() && $comments_posts == true ) {
            comments_template( '', true );
    
        } elseif ( is_page() && $comments_pages == true  && ! is_page_template( 'page-tpl-blog.php' ) ) {
    
            comments_template( '', true );
    
        } elseif ( is_attachment() && $comments_attachments == true ) {
    
            comments_template( '', true );
    
        }
    }
    
    ?>

    I am sorry, but you need to seek support from your theme vendor as we do not provide support for themes (free or paid) from commercial sources. Review: http://codex.wordpress.org/Forum_Welcome#Commercial_Products

    Thread Starter Dishman

    (@dishman)

    I am not asking for theme support, just how to code to remove the theme functionality and then put functionality in the child theme. This is not applicable to only this them. You asked about the theme I used, as I didn’t post it originally. I have read MANY other posts on the support forum that were similar in that they were trying to put code in a child theme to prevent theme updates from changing their site. Many of the topics specifically named the parent theme and support was still provided!

    I placed code in the above post. Can anyone help with why it is not working?

    This is not applicable to only this them.

    It is completely & utterly theme specific.

    We do not support commercial themes as you paid for support when you bought the theme. It is not our place to keep theme vendors in business or deprive them of any income that they may derive from support services.

    Thread Starter Dishman

    (@dishman)

    This is my first time asking for support and not a good experience. 1st it is a free theme (See my response to the question regarding what theme I used, 2nd I’m trying to learn wordpress child theme coding. There are volumes of support posts regarding how to do x in a child theme when y is in the parent theme. I have scoured the threads here and didn’t find exactly what would work. I found tons of similar issues on turning comments on/off in a child theme. Esmi even posted to some of these threads where someone mentioned using Tutorialicious by Anonymous as their theme!

    1st it is a free theme

    The wordpress.org support forums are meant for the core application, themes and plugins that are distributed on wordpress.org. We do not support themes downloaded from elsewhere. Even free ones.

    I’m trying to learn wordpress child theme coding

    And as you have already noted, the answers depend upon the parent theme – ie it is totally theme specific.

    I’m sorry but as you are using a non-WPORG theme, you need to seek support from the theme’s developers – paid or otherwise. We only support themes downloaded from wordpress.org here.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Enable Page, Post and Attachment via Child Theme’ is closed to new replies.