• I am building a custom front page within an Edin child theme on a local install of WordPress and would like to add a second featured page section. So far, I have used the existing featured pages section to highlight select blog posts. I have also added a custom full-width widget and now I would like to highlight three featured pages from past projects on my custom page. How would you recommend adding this new featured page section and be able to edit the links to the highlighted featured projects.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Hi there, I spoke with the theme’s developer and here is the guidance to accomplish what you’re after.

    In a child theme*:

    – copy the edin_featured_pages() function located in inc/template-tags.php and create your own based on this one.
    – create a new theme option file with 3 more theme options, similar to edin_featured_page_one_front_page in inc/customizer.php
    – reference the new customizer.php file in your child theme’s functions.php
    – finally, create a new page template based on page-templates/front-page.php with the new function you’ve just created.

    *Using a child theme means your tweaks won’t be overwritten when updating the theme. Here are some guides in case you haven’t made one before:

    http://codex.wordpress.org/Child_Themes
    http://op111.net/53/

    Dear Kathryn! I’m having same issue, thanks for advice, i managed to add everything else, BUT i want to have same layout in page-templates/front-page.php so when i change the line 18:

    <?php edin_featured_pages(); ?>

    to my new function:

    <?php edinchild_featured_pages(); ?>

    It gives me Fatal error:
    Fatal error: Call to undefined function edinstyle_featured_pages() in /home/……/page-templates/front-page.php on line 18

    WHAT TO DO?

    My child themes functions.php has this (only):

    /**
     * Customizer additions.
     */
    require_once( get_stylesheet_directory() . '/inc/customizer.php' );

    AND my customizer.php has this

    function edinchild_customize_register( $wp_customize ) {
    	$wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
    	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
    	$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
    
    	$wp_customize->add_section( 'edin_theme_options', array(
    		'title'    => __( 'Theme Options', 'edin-child' ),
    		'priority' => 130,
    	) );
    
    	/* Front Page: Featured Page Four */
    	$wp_customize->add_setting( 'edin_featured_page_four_front_page', array(
    		'default'           => '',
    		'sanitize_callback' => 'edin_sanitize_dropdown_pages',
    	) );
    	$wp_customize->add_control( 'edin_featured_page_four_front_page', array(
    		'label'             => __( 'Front Page: Featured Page Four', 'edin-child' ),
    		'section'           => 'edin_theme_options',
    		'priority'          => 11,
    		'type'              => 'dropdown-pages',
    	) );

    The customizer shows me 6 featured pages correctly, which i can choose, so only the page-template/front-page.php gives me the error…
    Many thanks for your help!

    Moderator Kathryn Presner

    (@zoonini)

    wplova – this is quite an advanced theme tweak to make, so while we can provide some guidance, it’s a bit beyond the scope of support we can provide.

    It sounds like you may have missed a couple of steps, like:

    – create a new theme option file with 3 more theme options, similar to edin_featured_page_one_front_page in inc/customizer.php
    – reference the new customizer.php file in your child theme’s functions.php

    You can’t just call the new function – you need to actually define it somewhere (we’d suggested a second, separate customizer file) so the theme knows what to do with it, otherwise you’ll get an “undefined” error.

    wplova

    (@wplova)

    Ok, I added customizer_new.php file, called it in functions.php, but no changes.

    How is Edin handling child themes, i mean, if I have function edin_customize_register it says customize_new.php error “cannot declare twice, because it’s already in edin theme”… So when i change function name to edinchild_customize_register it won’t work…

    Maybe it’s too advanced for me, but at least i have tried!

    It would be nice to have 6 featured articles to front page so that you can choose them from customizer… Can’t you add this automaticly to customizer, since people are asking here widely, how to get the front page with 6 featured articles, as in your template example…

    Moderator Kathryn Presner

    (@zoonini)

    If a function isn’t “pluggable” (i.e. it can’t be overridden in a child theme) then you need to first unhook it the parent’s function in your child theme, then add a new function in your child theme. Here are some resources on this topic:

    http://docs.presscustomizr.com/article/26-wordpress-actions-filters-and-hooks-a-guide-for-non-developers

    http://blog.teamtreehouse.com/hooks-wordpress-actions-filters-examples

    This isn’t actually a common request for Edin, so it’s not something we’ll be changing in the theme.

    Since I would like to add a second featured pages area to the front page of Edin as well, but this is for my own site, not for a client, is there a simpler way to do this than adding the functionality inside of customizr?

    I thought about using the guidance on this page https://jetpack.com/support/featured-content/ to allow me to set featured pages using categories or tags (after adding a plugin that supports adding categories and tags to pages). I think I’d then have to modify the front-page.php template to call that featured content.

    I would be happy to have it displayed as content is on the grid-page… can I borrowing and editing the conditional tags in this code snippet from grid-page.php?:

    <?php if ( $child_pages->have_posts() ) : ?>
    
    		<div id="quaternary" class="grid-area">
    			<div class="grid-wrapper clear">
    
    				<?php while ( $child_pages->have_posts() ) : $child_pages->the_post(); ?>
    
    					<div class="grid">
    						<?php get_template_part( 'content', 'grid' ); ?>
    					</div><!-- .grid -->
    
    				<?php endwhile; ?>

    Does this make sense?
    I’d appreciate some feedback about if I’m on the right track.

    If I’m all wrong, would simply setting the conditional to specify the set of 6 pages to feature using their slugs work?

    Hi @lwertz,

    Can you please start your own thread on this forum?

    It’s easier for us to support and keep up with different questions if they’re kept to separate threads. In addition, it will prevent the original poster from receiving further email notifications.

    The workaround you considered could work. You would need to create a copy of Edin’s front-page.php file in your child theme’s directory and then borrow all of the following from the parent’s page-templates/grid-page.php file:

    <?php
    		$child_pages = new WP_Query( array(
    			'post_type'      => 'page',
    			'orderby'        => 'menu_order',
    			'order'          => 'ASC',
    			'post_parent'    => $post->ID,
    			'posts_per_page' => 999,
    			'no_found_rows'  => true,
    		) );
    	?>
    
    	<?php if ( $child_pages->have_posts() ) : ?>
    
    		<div id="quaternary" class="grid-area">
    			<div class="grid-wrapper clear">
    
    				<?php while ( $child_pages->have_posts() ) : $child_pages->the_post(); ?>
    
    					<div class="grid">
    						<?php get_template_part( 'content', 'grid' ); ?>
    					</div><!-- .grid -->
    
    				<?php endwhile; ?>
    
    			</div><!-- .grid-wrapper -->
    		</div><!-- #quaternary -->
    
    	<?php
    		endif;
    		wp_reset_postdata();
    	?>

    The above would need to be inserted beneath <?php edin_featured_pages(); ?> and would display all pages that have been set as a child page to the static front page.

    If you’d like to discuss this option further, please start a new thread. 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Add a second featured page section to a custom front page’ is closed to new replies.