onepage sections with thumbnails as background
-
I’m creating a onepage. Pages are listed underneath each other and are display fullscreen. Each section should have the posts featured image as background. With my code in index.php it doesn’t work though:
<?php $args = array( 'sort_order' => 'ASC', 'sort_column' => 'menu_order', //post_title 'hierarchical' => 1, 'exclude' => '', 'child_of' => 0, 'parent' => -1, 'exclude_tree' => '', 'number' => '', 'offset' => 0, 'post_type' => 'page', 'post_status' => 'publish' ); $pages = get_pages($args); //start loop $count = 0; foreach ($pages as $page_data) { $count++; $content = apply_filters('the_content', $page_data->post_content); $title = $page_data->post_title; $slug = $page_data->post_name; $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'bg' ); ?> <section id="page-<?php echo $count; ?>" style="background-image: url('<?php echo $thumb['0'];?>')" class='page-section <?php echo "$slug" ?>'><a name='<?php echo "$slug" ?>'></a> <div class="wrap"> <h1><?php echo "$title" ?></h1> <?php echo "$content" ?> </div> </section> <?php } ?>When I check it in the browser with the inspector, I get the following code:
background-image: url('');
The topic ‘onepage sections with thumbnails as background’ is closed to new replies.