• Resolved david221

    (@david221)


    I’m in the middle of editing my functions.php file because I want to add in a custom slider on the home page. But after my edit, I’m getting a blank screen when I refresh site on my browser.

    I should also mention that I’m using the Skeleton theme for my site.

    I suppose it’s obvious that I haven’t written the code correctly, but I don’t know where to pin point where.

    /*-----------------------------------------------------------------------------------*/
    // Content Wrap Markup - skeleton_content_wrap()
    // Be sure to add the excess of 16 to skeleton_before_sidebar() as well
    /*-----------------------------------------------------------------------------------*/
    
    if ( !function_exists( 'skeleton_content_wrap' ) )  {
    
    	function skeleton_content_wrap() {
    
    	$columns = '';
    	$columns = apply_filters('skeleton_set_colwidth', $columns, 1);
    	$latest_blog_posts = new WP Query( array ( 'posts_per_page'  => 1 ) );
    
    	echo '<a id="top"></a>';
    	if ( is_front_page() ) {
    		if($latest_blog_posts->have_posts()) {
    
    	echo "<div class=\"home-slider\">";
    	echo "<div class=\"homepage-slider\">";
    		echo '<img src="'.get_site_url.'/wp-content/uploads/2015/02/slider01.jpg">';
    		echo '<img src="'.get_site_url.'/wp-content/uploads/2015/02/slider02.jpg">'; 
    
    	while ($latest_blog_posts->have_posts()) {
    		$latest_blog_posts->the_post();
    
    	echo "<div class=\"image\">";
    		echo "<div class=\"slide\">";
    
    				echo "<div class=\"slide_image\">";
    					echo the_post_thumbnail();
    				echo "</div>";
    				echo "<div class=\"slide_title\">";
    					echo the_title();
    				echo "</div>";
    			echo "</a>";
    	echo "</div>";
    
    	endwhile;
    		}
    	}
    	}
    
    	echo "</div>";
    	echo "</div>";
    	echo "</div>";
    	echo "</div>";
    	} else {
    	/*echo '<h1 class="entry-title">';*/
    /*	echo the_title();*/
    	/*echo '</h1>';*/
    	}
    	echo "<div id=\"wrap\" class=\"container\">";
    	echo '<div class="entry-content">';
    	echo '<div id="content" class="'.$columns.' columns">';
    	}
    	add_action( 'skeleton_before_content', 'skeleton_content_wrap', 1 );
    }

    I’d appreciate the help.

Viewing 1 replies (of 1 total)
  • Thread Starter david221

    (@david221)

    Never mind, I worked it out by structuring my code carefully.

    /*-----------------------------------------------------------------------------------*/
    // Content Wrap Markup - skeleton_content_wrap()
    // Be sure to add the excess of 16 to skeleton_before_sidebar() as well
    /*-----------------------------------------------------------------------------------*/
    
    if ( !function_exists( 'skeleton_content_wrap' ) )  {
    
    	function skeleton_content_wrap() {
    	$latest_blog_posts = new WP_Query( array( 'posts_per_page' => 1 ) );
    	$columns = '';
    	$columns = apply_filters('skeleton_set_colwidth', $columns, 1);
    
    	echo '<a id="top"></a>';
    
    if ( is_front_page() ) {
    if($latest_blog_posts->have_posts()):
    	echo "<div class=\"home-slider\">";
    	echo "<div class=\"homepage-slider\">";
    		echo '<img src="'.get_site_url.'/wp-content/uploads/2015/02/slider01.jpg">';
    	echo "</div>";
    		while ($latest_blog_posts->have_posts()):
                $latest_blog_posts->the_post();
    		echo "<div class=\"image\">";
    		echo "<div class=\"slide\">";
    
    				echo "<div class=\"slide_image\">";
    					echo the_post_thumbnail();
    				echo "</div>";
    				echo "<div class=\"slide_title\">";
    					echo the_title();
    				echo "</div>";
    			echo "</a>";
    
    	echo "</div>";
    
    	endwhile;
    	echo "</div>";
    	echo "</div>";
    	endif;
    		 wp_reset_postdata();
    
    	} else {
    	/*echo '<h1 class="entry-title">';*/
    /*	echo the_title();*/
    	/*echo '</h1>';*/
    	}
    	echo "<div id=\"wrap\" class=\"container\">";
    	echo '<div class="entry-content">';
    	echo '<div id="content" class="'.$columns.' columns">';
    	}
    	add_action( 'skeleton_before_content', 'skeleton_content_wrap', 1 );
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Editing 'if home page' in functions.php renders blank screen – Skeleton Theme’ is closed to new replies.