badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

How do I display the featured image on a page?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #27966
    dave69
    Participant

    It displays on a blog post fine, but how do you display the featured image on a page?

    Thanks

    #27967
    dave69
    Participant

    And I guess when someone looks at this, a couple other questions:

    1) How do I remove the comments from from pages? (without needing to do it on each individual page)

    2) Where is the documentation on the various loops that appear to be available?

    Thanks.

    #28049

    Hi dave69,

    It needs code customization. You may add the image in the editor of the page. Using featured image will work on business template as you can see in services and recent work. That image is displayed from the featured image. If you like to display in other page too then customize the code. The below code is used to display the featured image. https://codex.wordpress.org/Function_Reference/has_post_thumbnail

    if ( has_post_thumbnail() ) {
    	the_post_thumbnail();
    }
    else {
    	echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/thumbnail-default.jpg" />';
    }

    Got to theme folder -> inc -> structure -> content-extension.php on line no 201 to 260. You need to add the above code. Then your featured image will be displayed.

    While customizing the code first of all create a child theme then only customize the code to be safe from data loss. If you make direct changes in the code then you need to make the same customization again and again while updating to new version.

    Thank you!

    #28051
    dave69
    Participant

    And the other two items I asked about?

    Thanks.

    #28073
    dave69
    Participant

    Your instructions for displaying the image are not working. I created a child theme file with the same file structure, and it’s not showing that file.

    #28121

    Hi dave69,

    Creating the same file structure will not override or work with the child theme. You need to unhook the function and customize the code. We have replied many times how to unhook the functions.
    View this below link we have already described how to unhook
    https://www.themehorse.com/support-forum/topic/loading-header-extension-php-in-child-theme/

    Regarding to your above questions
    1) How do I remove the comments from from pages? (without needing to do it on each individual page)
    ==> This is wordpress default feature. Before wordpress 4.3 you need to do it manually. But i think now in 4.3 version there comments are automatically off by default.
    View this below link
    https://wordpress.org/news/
    Comments turned off on pages – All new pages that you create will have comments turned off. Keep discussions to your blog, right where they’re supposed to happen.

    2) Where is the documentation on the various loops that appear to be available?
    ==> Which loop are you talking about. if you are talking about the post or page look then you go to the theme folder -> inc -> structure-> content-extension.php

    In this page we have defined all the loop.

    Hope this may help you
    Thank you!

    #28132
    dave69
    Participant

    1) If I turn of comments in setting that turns it off for all pages AND posts. There should be away to remove the comments form from pages (not posts) site wide. With normal themes, you would simply remove from the pages template. With a theme such as Genesis, you would use a hook to do so.

    2) I’ve seen that page, and followed the advice. It either didn’t work or gave me an error. Can you show me the EXACT code I would need to add to have a custom “content-extensions.php” in the child theme?

    Thanks.

    #28133
    dave69
    Participant

    At present I’ve had to make a clone of your theme and edit the theme itself, which is not what I’d prefer to do, but had to sort out these issues until getting info that works.

    #28161

    Hi dave69,

    1) If I turn of comments in setting that turns it off for all pages AND posts. There should be away to remove the comments form from pages (not posts) site wide. With normal themes, you would simply remove from the pages template. With a theme such as Genesis, you would use a hook to do so.

    => To disable comment in every page only then there is only two options. Either you need to do manually from admin for each and every single page or you need code customization.

    The file is inside theme folder -> inc -> structure -> content-extension.php on line no 201 to 261.

    You may remove this code which is on line no 240 comments_template();

    Hope this may help you

    2) I’ve seen that page, and followed the advice. It either didn’t work or gave me an error. Can you show me the EXACT code I would need to add to have a custom “content-extensions.php” in the child theme?
    ==> To overide the default content-extension.php you need to create a child theme with style.css and functions.php file.

    Under functions.php file you need to customize the code. First you need to unhook the functions and then customize the code.
    Below i have added some code. Hope this may help you

    Example:
    // Unhook default Thematic functions
    function unhook_thematic_functions() {
        // Don't forget the position number if the original function has one
    
    remove_action( 'interface_loop_content', 'interface_theloop', 10 );
    
    }
    add_action('init','unhook_thematic_functions'); 
    
    add_action( 'interface_loop_content', 'interface_theloop_child', 10 );
    
    function interface_theloop_child() {
    	if( is_page() ) {
    		if( is_page_template( 'page-templates/page-template-blog-image-large.php' ) ) {
    			
    			interface_theloop_for_template_blog_image_large();
    			
    		}
    		elseif( is_page_template( 'page-templates/page-template-blog-image-medium.php' ) ) {
    			interface_theloop_for_template_blog_image_medium();
    		}
    		elseif( is_page_template( 'page-templates/page-template-blog-full-content.php' ) ) {
    			
    			interface_theloop_for_template_blog_full_content();
    			
    		}
    		else {
    			interface_theloop_for_page();
    		}
    	}
    	elseif( is_single() ) {
    		interface_theloop_for_single();
    	}
    	elseif( is_search() ) {
    		interface_theloop_for_search();
    	}
    	else {
    		interface_theloop_for_archive();
    	}
    }
    
    // If you like to remove the comment sections from page only then paste this functions
    //Important: Add other functions also where you don't want changing too. Because you have removed all the core functions using remove_action functions. So if there is no change in archive and other functions like interface_theloop_for_archive(), interface_theloop_for_search(), interface_theloop_for_single() then you copy all the code for this functions too. Just i have done for interface_theloop_for_page() too
    
    /****************************************************************************************/
    
    if ( ! function_exists( 'interface_theloop_for_page' ) ) :
    /**
     * Fuction to show the page content.
     */
    function interface_theloop_for_page() {
    	global $post;
    
    	if( have_posts() ) {
    		while( have_posts() ) {
    			the_post();
    
    			do_action( 'interface_before_post' );
    ?>
    <section id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
      <article>
        <?php do_action( 'interface_before_post_header' ); ?>
        <?php do_action( 'interface_after_post_header' ); ?>
        <?php do_action( 'interface_before_post_content' ); ?>
        <div class="entry-content clearfix">
          <?php the_content(); ?>
          <?php
        				wp_link_pages( array( 
    						'before'            => '<div style="clear: both;"></div><div class="pagination clearfix">'.__( 'Pages:', 'interface' ),
    						'after'             => '</div>',
    						'link_before'       => '<span>',
    						'link_after'        => '</span>',
    						'pagelink'          => '%',
    						'echo'              => 1 
                   ) );
        			?>
        </div>
        <!-- entry-content clearfix-->
        
        <?php 
    
      			do_action( 'interface_after_post_content' );
    
      			do_action( 'interface_before_comments_template' ); 
    
             do_action ( 'interface_after_comments_template' );
    
             ?>
      </article>
    </section>
    <?php
    			do_action( 'interface_after_post' );
    
    		}
    	}
    	else {
    		?>
    <h2 class="entry-title">
      <?php _e( 'No Posts Found.', 'interface' ); ?>
    </h2>
    <?php
       }
    }
    endif;

    If you are still unable then you need to hire a developer

    Thank you!

    #28162

    Hi dave69,

    1) If I turn of comments in setting that turns it off for all pages AND posts. There should be away to remove the comments form from pages (not posts) site wide. With normal themes, you would simply remove from the pages template. With a theme such as Genesis, you would use a hook to do so.

    => To disable comment in every page only then there is only two options. Either you need to do manually from admin for each and every single page or you need code customization.

    The file is inside theme folder -> inc -> structure -> content-extension.php on line no 201 to 261.

    You may remove this code which is on line no 240 comments_template();

    Hope this may help you

    2) I’ve seen that page, and followed the advice. It either didn’t work or gave me an error. Can you show me the EXACT code I would need to add to have a custom “content-extensions.php” in the child theme?
    ==> To overide the default content-extension.php you need to create a child theme with style.css and functions.php file.

    Under functions.php file you need to customize the code. First you need to unhook the functions and then customize the code.
    Below i have added some code. Hope this may help you

    Example:
    // Unhook default Thematic functions
    function unhook_thematic_functions() {
        // Don't forget the position number if the original function has one
    
    remove_action( 'interface_loop_content', 'interface_theloop', 10 );
    
    }
    add_action('init','unhook_thematic_functions'); 
    
    add_action( 'interface_loop_content', 'interface_theloop_child', 10 );
    
    function interface_theloop_child() {
    	if( is_page() ) {
    		if( is_page_template( 'page-templates/page-template-blog-image-large.php' ) ) {
    			
    			interface_theloop_for_template_blog_image_large();
    			
    		}
    		elseif( is_page_template( 'page-templates/page-template-blog-image-medium.php' ) ) {
    			interface_theloop_for_template_blog_image_medium();
    		}
    		elseif( is_page_template( 'page-templates/page-template-blog-full-content.php' ) ) {
    			
    			interface_theloop_for_template_blog_full_content();
    			
    		}
    		else {
    			interface_theloop_for_page();
    		}
    	}
    	elseif( is_single() ) {
    		interface_theloop_for_single();
    	}
    	elseif( is_search() ) {
    		interface_theloop_for_search();
    	}
    	else {
    		interface_theloop_for_archive();
    	}
    }
    
    // If you like to remove the comment sections from page only then paste this functions
    //Important: Add other functions also where you don't want changing too. Because you have removed all the core functions using remove_action functions. So if there is no change in archive and other functions like interface_theloop_for_archive(), interface_theloop_for_search(), interface_theloop_for_single() then you copy all the code for this functions too. Just i have done for interface_theloop_for_page() too
    
    /****************************************************************************************/
    
    if ( ! function_exists( 'interface_theloop_for_page' ) ) :
    /**
     * Fuction to show the page content.
     */
    function interface_theloop_for_page() {
    	global $post;
    
    	if( have_posts() ) {
    		while( have_posts() ) {
    			the_post();
    
    			do_action( 'interface_before_post' );
    ?>
    <section id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
      <article>
        <?php do_action( 'interface_before_post_header' ); ?>
        <?php do_action( 'interface_after_post_header' ); ?>
        <?php do_action( 'interface_before_post_content' ); ?>
        <div class="entry-content clearfix">
          <?php the_content(); ?>
          <?php
        				wp_link_pages( array( 
    						'before'            => '<div style="clear: both;"></div><div class="pagination clearfix">'.__( 'Pages:', 'interface' ),
    						'after'             => '</div>',
    						'link_before'       => '<span>',
    						'link_after'        => '</span>',
    						'pagelink'          => '%',
    						'echo'              => 1 
                   ) );
        			?>
        </div>
        <!-- entry-content clearfix-->
        
        <?php 
    
      			do_action( 'interface_after_post_content' );
    
      			do_action( 'interface_before_comments_template' ); 
    
             do_action ( 'interface_after_comments_template' );
    
             ?>
      </article>
    </section>
    <?php
    			do_action( 'interface_after_post' );
    
    		}
    	}
    	else {
    		?>
    <h2 class="entry-title">
      <?php _e( 'No Posts Found.', 'interface' ); ?>
    </h2>
    <?php
       }
    }
    endif;

    If you are still unable then you need to hire a developer

    Thank you!

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.