Ich möchte eine Singlepage-Seite erstellen. Die Seiten werden jeweils untereinander aufgelistet und als sections ausgegeben. Jede section soll das Beitragsbild als Hintergrund haben. Mit meinem Code in index.php klappt das aber nicht:
PHP
<?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 } ?>
Alles anzeigen
Wenn ich im Inspektor dann die gewünschte section auswähle und im CSS prüfe, erscheint: