WordPress.org

Ready to get started?Download WordPress

Forums

Single page Theme & Template page (2 posts)

  1. nathinah
    Member
    Posted 1 year ago #

    Hello everybody!

    I have been going crazy dealing with a single page theme like this one.

    I managed to have a loop of the pages in the index.php and link them through the WP menu. However when I try and give a different structure to the various sections issues arise.
    The code that I used for this loop is the following:

    <?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
    foreach ($pages as $page_data) {
        $content = apply_filters('the_content', $page_data->post_content);
        $title = $page_data->post_title;
        $slug = $page_data->post_name;
    ?>
    
    <div id='<?php echo "$slug" ?>' class="section">
    <div class="contentSlide">
    <h2><?php echo "$title" ?></h2>
    <?php echo "$content" ?>
    </div>
    </div>
    
    <?php }; ?>

    This shows all the pages one after the other.

    What I want to do is assign a different structure depending on the template of the page (e.g. a different template for the gallery, one for the portfolio, one for the about page, ...) with a code like that:

    <?php if ( !is_page_template ('pagePortfolio.php')) { ?>
    <div class="some_class_for_portfolio_page">SOME CONTENT</div>
    <?php } else { ?>
    <div class="some_class_for_not_portfolio_page">SOME DIFFERENT CONTENT</div>
    <?php } ?>

    ....but that does not work at all :(
    Anyone has an idea? Pleeeeeease <3<3<3

  2. esmi
    Forum Moderator
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic