Skip to main content
I query every pages and position each page using if statement, after a certain page I introduced the categories and position certain category using if statement again.
Source Link
cmsdeployed
  • 389
  • 3
  • 7
  • 19
                <?php
    $pages = get_pages(array (
        'post_type' => 'page',
        'sort_column' => 'menu_order',
        ));
    foreach ($pages as $page) {
        $apage = $page->post_name; ?>
                <?php if ( $apage =='about') { ?>
                <article id="<?php echo $page->post_name; ?>">
                    <header class="entry-header">
                        <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                        <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
            </header>
        </header>
    <div class="entry-summary">
               <div <class="entry-summary"><?php echo apply_filters('the_content', $page->post_content); ?>></div>
                </div>article>

 <!-- ## Now Hold the pages query </article>to introduce the categories ## -->

                <?php
                // get all the categories from the database
                $cats = get_categories(); 
      
        
         // loop through the categries
                foreach ($cats as $cat) {
                    // setup the cateogory ID
                    $cat_id= $cat->term_id;
                    // Make a header for the cateogry
                    /* if ( in_category('reviews') ) : */
                    echo '<header class="entry-header">'.$cat->name.'</header>';
                    // create a custom wordpress query
                    $args = array('cat=$cat_id&posts_per_page=5');
                    $the_query = new WP_Query( $args );
                    // start the wordpress loop!
                    if ($the_query->have_posts()) : 
                        while ($the_query->have_posts()) : 
                            $the_query->the_post();
                            // create our link now that the post is setup ?>
                        <article id="<<?php echo $page->post_name; ?>">
  if ( (in_category('reviews')) /*& ( category_slug == 'reviews' )*/ ) : ?>  
          <?php if ( (in_category('reviews')) ) : ?><article id="cat-reviews">
                        <header class="entry-header">
                            <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                            <h2 class="entry-title"><?php the_title(); ?></h2>
                        </header>
                        <div class="entry-summary"><?php the_excerpt(); ?></div>
                    </article><!-- #cat-reviews -->
                    
                    <!-- ## More if categories as needed ## -->
                    
                    <?php endif; ?>
                </article>?php
            <?php            endwhile;
                    endif; // done our wordpresscategories loop. 
 Will start again for each category
              /* endif; // done specific category */
                } // done the foreach statement
                
                /* 
                 * getting back to our page query 
                 */
                 
            } elseif ( $apage =='contact') { ?>
                <article id="<?php echo $page->post_name; ?>">
                    <header class="entry-header">
                        <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
                    </header>
                    <div class="entry-summary"><?php echo apply_filters('the_content', $page->post_content); ?></div>
                </article>
            
            <!-- ## More if pages as needed ## -->
            
                <?php } // end if
            } // end foreach ?>
</div>
<?php
$pages = get_pages(array ('post_type' => 'page','sort_column' => 'menu_order'));
foreach ($pages as $page) {
    $apage = $page->post_name;
    if ( $apage =='about') { ?>
        <article id="<?php echo $page->post_name; ?>">
            <header class="entry-header">
                <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
            </header>
            <div class="entry-summary">
                <?php echo apply_filters('the_content', $page->post_content); ?>
            </div>
        </article>
        <?php
        // get all the categories from the database
        $cats = get_categories(); 
             
         // loop through the categries
        foreach ($cats as $cat) {
            // setup the cateogory ID
            $cat_id= $cat->term_id;
            // Make a header for the cateogry
            if ( in_category('reviews') ) :
                echo '<header class="entry-header">'.$cat->name.'</header>';
                // create a custom wordpress query
                $args = array('cat=$cat_id&posts_per_page=5');
                $the_query = new WP_Query( $args );
                // start the wordpress loop!
                if ($the_query->have_posts()) : 
                    while ($the_query->have_posts()) : 
                        $the_query->the_post();
                        // create our link now that the post is setup ?>
                        <article id="<?php echo $page->post_name; ?>">
                        <?php if ( (in_category('reviews')) ) : ?> 
                        <header class="entry-header">
                            <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                            <h2 class="entry-title"><?php the_title(); ?></h2>
                        </header>
                        <div class="entry-summary"><?php the_excerpt(); ?></div>
                    <?php endif; ?>
                </article>
            <?php endwhile;
        endif; // done our wordpress loop. Will start again for each category
    endif; // done specific category
} // done the foreach statement
} elseif ( $apage =='contact') { ?>
<article id="<?php echo $page->post_name; ?>">
    <header class="entry-header">
        <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
    </header>
    <div class="entry-summary"><?php echo apply_filters('the_content', $page->post_content); ?></div>
</article>
<?php } // end if
} // end foreach ?>
</div>
                <?php
    $pages = get_pages(array (
        'post_type' => 'page',
        'sort_column' => 'menu_order',
        ));
    foreach ($pages as $page) {
        $apage = $page->post_name; ?>
                <?php if ( $apage =='about') { ?>
                <article id="<?php echo $page->post_name; ?>">
                    <header class="entry-header">
                        <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                        <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
                    </header>
                    <div class="entry-summary"><?php echo apply_filters('the_content', $page->post_content); ?></div>
                </article>

 <!-- ## Now Hold the pages query to introduce the categories ## -->

                <?php
                // get all the categories from the database
                $cats = get_categories(); 
      
                // loop through the categries
                foreach ($cats as $cat) {
                    // setup the cateogory ID
                    $cat_id= $cat->term_id;
                    // Make a header for the cateogry
                    /* if ( in_category('reviews') ) : */
                    echo '<header class="entry-header">'.$cat->name.'</header>';
                    // create a custom wordpress query
                    $args = array('cat=$cat_id&posts_per_page=5');
                    $the_query = new WP_Query( $args );
                    // start the wordpress loop!
                    if ($the_query->have_posts()) : 
                        while ($the_query->have_posts()) : 
                            $the_query->the_post();
                            // create our link now that the post is setup ?>
                <?php if ( (in_category('reviews')) /*& ( category_slug == 'reviews' )*/ ) : ?>  
                <article id="cat-reviews">
                    <header class="entry-header">
                        <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                        <h2 class="entry-title"><?php the_title(); ?></h2>
                    </header>
                    <div class="entry-summary"><?php the_excerpt(); ?></div>
                    </article><!-- #cat-reviews -->
                    
                    <!-- ## More if categories as needed ## -->
                    
                    <?php endif; ?>
                <?php
                        endwhile;
                    endif; // done our categories loop. 
                    /* endif; // done specific category */
                } // done the foreach statement
                
                /* 
                 * getting back to our page query 
                 */
                 
            } elseif ( $apage =='contact') { ?>
                <article id="<?php echo $page->post_name; ?>">
                    <header class="entry-header">
                        <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
                    </header>
                    <div class="entry-summary"><?php echo apply_filters('the_content', $page->post_content); ?></div>
                </article>
            
            <!-- ## More if pages as needed ## -->
            
                <?php } // end if
            } // end foreach ?>
I query every pages and position each page using if statement, after a certain page I introduced the categories and position certain category using if statement again.
Source Link
cmsdeployed
  • 389
  • 3
  • 7
  • 19

Thanks for the previous answer. There mights be a misunderstanding. I didn't think your comment was rude @Pieter Goosen and mine wasn't with intention either. Anyway. I was able to come up with the bellow queries. I am querying categories inside pages. Don't know if it truly the proper way, but it works for me. I still have to do more digging to cleanup and see if there is any adverse effect. But so far I am getting exactly what I needed and with additionallyadditional tweaks, I will be able to style my pages and categories aslike I need to.

Thanks for the previous answer. There mights be a misunderstanding. I didn't think your comment was rude @Pieter Goosen and mine wasn't with intention either. Anyway. I was able to come up with the bellow queries. I am querying categories inside pages. Don't know if it truly the proper way, but it works for me. I still have to do more digging to cleanup and see if there is any adverse effect. But far I am getting exactly what I needed and with additionally tweaks, I will be able to style my pages and categories as I need to.

Thanks for the previous answer. There mights be a misunderstanding. I didn't think your comment was rude @Pieter Goosen and mine wasn't with intention either. Anyway. I was able to come up with the bellow queries. I am querying categories inside pages. Don't know if it truly the proper way, but it works for me. I still have to do more digging to cleanup and see if there is any adverse effect. But so far I am getting exactly what I needed and with additional tweaks, I will be able to style my pages and categories like I need to.

I query every pages and position each page using if statement, after a certain page I introduced the categories and position certain category using if statement again.
Source Link
cmsdeployed
  • 389
  • 3
  • 7
  • 19

Thanks for the previous answer. There mightmights be a misunderstanding. I didn't think your comment was rude @Pieter Goosen and mine was withoutwasn't with intention either. Anyway. I was able to come up with the bellow queries. I am querying categories inside pages. Don't know if it truly the proper way, but it works for me. I still have to do more digging to cleanup and see if there is any adverse effect. But far I am getting exactly what I needed and with additionally tweaks, I will be able to style my pages and categories as I need to.

                        <?php
            $pages = get_pages(array (
                'post_type' => 'page',
                'sort_column' => 'menu_order',
                ));
            foreach ($pages as $page) {
                $apage = $page->post_name; ?>
                        <?php if ( $apage =='about') { ?>
                        <article id="<?php echo $page->post_name; ?>">
                            <header class="entry-header">
                                <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                                <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
                            </header>
            <div class="entry-summary">
               <div class="entry-summary"><<?php echo apply_filters('the_content', $page->post_content); ?></div>>
                </div>
        </article>
                        <?php
                        // get all the categories from the database
                        $cats = get_categories(); 
             
                        // loop through the categries
                        foreach ($cats as $cat) {
                            // setup the cateogory ID
                            $cat_id= $cat->term_id;
                            // Make a header for the cateogry
                            if ( in_category('reviews') ) :
                            echo '<header class="entry-header">'.$cat->name.'</header>';
                            // create a custom wordpress query
                            $args = array('cat=$cat_id&posts_per_page=5');
                            $the_query = new WP_Query( $args );
                            // start the wordpress loop!
                            if ($the_query->have_posts()) : 
                                while ($the_query->have_posts()) : 
                                    $the_query->the_post();
                                    // create our link now that the post is setup ?>
                        <article id="<?php echo $page->post_name; ?>">
                        <?php if ( (in_category('reviews')) /*& ( category_slug == 'reviews' )*/ ) : ?> 
                            <header class="entry-header">
                                <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                                <h2 class="entry-title"><?php the_title(); ?></h2>
                            </header>
                            <div class="entry-summary"><?php the_excerpt(); ?></div>
                            <?php endif; ?>
                        </article>
                        <?php
                                endwhile;
                            endif; // done our wordpress loop. Will start again for each category
                            endif; // done specific category
                        } // done the foreach statement
                    } elseif ( $apage =='contact') { ?>
                        <article id="<?php echo $page->post_name; ?>">
                            <header class="entry-header">
                                <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
                            </header>
                            <div class="entry-summary"><?php echo apply_filters('the_content', $page->post_content); ?></div>
                        </article>
                        <?php } // end if
                    } // end foreach ?>
                    </div>

Thanks for the previous answer. There might be a misunderstanding. I didn't think your comment was rude and mine was without intention either. Anyway. I was able to come up with the bellow queries. I querying categories inside pages. Don't know if it truly the proper way, but it works for me. I still have to do more digging to cleanup and see if there is any adverse effect. But far I am getting exactly what I needed and with additionally tweaks, I will be able to style my pages and categories as I need to.

                        <?php
            $pages = get_pages(array (
                'post_type' => 'page',
                'sort_column' => 'menu_order',
                ));
            foreach ($pages as $page) {
                $apage = $page->post_name; ?>
                        <?php if ( $apage =='about') { ?>
                        <article id="<?php echo $page->post_name; ?>">
                            <header class="entry-header">
                                <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                                <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
                            </header>
                            <div class="entry-summary"><?php echo apply_filters('the_content', $page->post_content); ?></div>
                        </article>
                        <?php
                        // get all the categories from the database
                        $cats = get_categories(); 
             
                        // loop through the categries
                        foreach ($cats as $cat) {
                            // setup the cateogory ID
                            $cat_id= $cat->term_id;
                            // Make a header for the cateogry
                            if ( in_category('reviews') ) :
                            echo '<header class="entry-header">'.$cat->name.'</header>';
                            // create a custom wordpress query
                            $args = array('cat=$cat_id&posts_per_page=5');
                            $the_query = new WP_Query( $args );
                            // start the wordpress loop!
                            if ($the_query->have_posts()) : 
                                while ($the_query->have_posts()) : 
                                    $the_query->the_post();
                                    // create our link now that the post is setup ?>
                        <article id="<?php echo $page->post_name; ?>">
                        <?php if ( (in_category('reviews')) /*& ( category_slug == 'reviews' )*/ ) : ?> 
                            <header class="entry-header">
                                <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                                <h2 class="entry-title"><?php the_title(); ?></h2>
                            </header>
                            <div class="entry-summary"><?php the_excerpt(); ?></div>
                            <?php endif; ?>
                        </article>
                        <?php
                                endwhile;
                            endif; // done our wordpress loop. Will start again for each category
                            endif; // done specific category
                        } // done the foreach statement
                    } elseif ( $apage =='contact') { ?>
                        <article id="<?php echo $page->post_name; ?>">
                            <header class="entry-header">
                                <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
                            </header>
                            <div class="entry-summary"><?php echo apply_filters('the_content', $page->post_content); ?></div>
                        </article>
                        <?php } // end if
                    } // end foreach ?>
                    </div>

Thanks for the previous answer. There mights be a misunderstanding. I didn't think your comment was rude @Pieter Goosen and mine wasn't with intention either. Anyway. I was able to come up with the bellow queries. I am querying categories inside pages. Don't know if it truly the proper way, but it works for me. I still have to do more digging to cleanup and see if there is any adverse effect. But far I am getting exactly what I needed and with additionally tweaks, I will be able to style my pages and categories as I need to.

<?php
$pages = get_pages(array ('post_type' => 'page','sort_column' => 'menu_order'));
foreach ($pages as $page) {
    $apage = $page->post_name;
    if ( $apage =='about') { ?>
        <article id="<?php echo $page->post_name; ?>">
            <header class="entry-header">
                <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
            </header>
            <div class="entry-summary">
                <?php echo apply_filters('the_content', $page->post_content); ?>
            </div>
        </article>
        <?php
        // get all the categories from the database
        $cats = get_categories(); 
             
        // loop through the categries
        foreach ($cats as $cat) {
            // setup the cateogory ID
            $cat_id= $cat->term_id;
            // Make a header for the cateogry
            if ( in_category('reviews') ) :
                echo '<header class="entry-header">'.$cat->name.'</header>';
                // create a custom wordpress query
                $args = array('cat=$cat_id&posts_per_page=5');
                $the_query = new WP_Query( $args );
                // start the wordpress loop!
                if ($the_query->have_posts()) : 
                    while ($the_query->have_posts()) : 
                        $the_query->the_post();
                        // create our link now that the post is setup ?>
                        <article id="<?php echo $page->post_name; ?>">
                        <?php if ( (in_category('reviews')) ) : ?> 
                        <header class="entry-header">
                            <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { the_post_thumbnail(); } ?>
                            <h2 class="entry-title"><?php the_title(); ?></h2>
                        </header>
                        <div class="entry-summary"><?php the_excerpt(); ?></div>
                    <?php endif; ?>
                </article>
            <?php endwhile;
        endif; // done our wordpress loop. Will start again for each category
    endif; // done specific category
} // done the foreach statement
} elseif ( $apage =='contact') { ?>
<article id="<?php echo $page->post_name; ?>">
    <header class="entry-header">
        <h2 class="entry-title"><?php echo $page->post_title; ?></h2>
    </header>
    <div class="entry-summary"><?php echo apply_filters('the_content', $page->post_content); ?></div>
</article>
<?php } // end if
} // end foreach ?>
</div>
Source Link
cmsdeployed
  • 389
  • 3
  • 7
  • 19
Loading