0

Im using a plugin to create slides, and typically you have a structure where a parentpage with vertical slides is defined by a class, and then a child inside that container is defined by another class to create horizontal slides inside the parentage. This is how the structure is needed for this work:

<div class="section"> <div class="slide"> Slide 1 </div> <div class="slide"> Slide 2 </div> <div class="slide"> Slide 3 </div> <div class="slide"> Slide 4 </div> </div>

however, I'm implanting this to wordpress and have a loop that creates vertical slides from pages automatically, but this makes horizontal pages trickier.

So i wonder if i can make a loop that creates the needed htmlstructure, and maybe a subquery? to put a class on child pages and place them in the parent container?

`if (($locations = get_nav_menu_locations()) && $locations['main-nav'] ) { $menu = wp_get_nav_menu_object( $locations['main-nav'] ); $menu_items = wp_get_nav_menu_items($menu->term_id); $pageID = array(); foreach($menu_items as $item) { if($item->object == 'page') $pageID[] = $item->object_id;

    }

query_posts( array( 'post_type' => 'page','post__in' => $pageID, 'posts_per_page' => count($pageID), 'orderby' => 'post__in' ) );

} while(have_posts() ) : the_post();

?>

post_name;?>" class="section"> --> post_name;?>" class="section" data-anchor="post_name;?>">`

1 Answer 1

1

try this code

$a = 5; //number of slides you wanted
$b = 3; //number of parent div
$string = '';
for($i=0;$i<$b;$i++)
{
  $string .= '<div class="section">';
  for($j=0;$j<$a;$j++)
  {
   $string .= ' <div class="slide"> Slide '.$j.' </div>';
  }
 $string .= "</div>"
}

you should try this.. while loop inside while loop.. I am not sure this will work or not... But give it a try

<?php get_header(); ?>

<!-- Post all pages content -->
 <?php    if (($locations = get_nav_menu_locations()) && $locations['main-nav'] ) {
    $menu = wp_get_nav_menu_object( $locations['main-nav'] );
    $menu_items = wp_get_nav_menu_items($menu->term_id);
    $pageID = array();
    foreach($menu_items as $item) {
        if($item->object == 'page')
            $pageID[] = $item->object_id;
    }
query_posts( array( 'post_type' => 'page','post__in' => $pageID, 'posts_per_page' => count($pageID), 'orderby' => 'post__in' ) );
}
while(have_posts() ) : the_post();      
?>


<!--     <div id="<?php echo $post->post_name;?>" class="section"> -->
<div id="content2">
 <?php while(have_posts() ) : the_post(); ?>

    <div id="pageSlide-<?php echo $post->post_name;?>" class="section" data-anchor="<?php echo $post->post_name;?>">

        <div id="inner-content" class="wrap clearfix">

            <div id="main" class="twelvecol first clearfix" role="main">

                <article id="post-<?php the_ID(); ?>" <?php post_class( 'clearfix' ); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">

                            <header class="article-header">

                                <h1 class="page-title"><?php the_title(); ?></h1>

                            </header>

                            <section class="entry-content clearfix" itemprop="articleBody">
                                <?php the_content(); ?>
                            </section>

                            <footer class="article-footer">
                                <p class="clearfix"><?php the_tags( '<span class="tags">' . __( 'Tags:', 'bonestheme' ) . '</span> ', ', ', '' ); ?></p>

                            </footer>

                </article>

            </div>

        </div>
    </div>

</div> <!-- end of page div-->

`

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for the suggestion, sorry for asking stupid question, but how do i incorporate that code, is it part of a loop or a function? Im not that good at php, but with the right pushes and google and ill try to solve it. Edited my orogonal post with my loop.. Or tried atleast, the formating came out wierd, hope it makes sense.
no problem, just copy paste this code to where you want to generate your slides.
Thanks again, but I'm still unsure how to add it to my loop. Thanks for the reply though!
give the whole page code to me.. and let me know where do you want your slides in your page..
I appreciate the help! Heres the custom template im using: dropbox.com/s/y5ymicycwahi7z3/home.php I have a custom walker that calls the pages as anhcorlinks, and creates the class "section" for pages, wich creates slides. I need to set the class "slide" for childpages, and have them output in the parent container. Thanks for the effort again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.