• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Php Code in neuen Div Container laden

Hallo,

ich habe folgenden Code in einem Theme:
  1. <div class="tabs">
  2. <ul class="tabNavigation">

  3. <?php
  4. if(of_get_option('homepage_content', 'yes') == 'yes'):
  5. ?>
  6. <li><a href="#main"><?php the_title(); ?></a></li>
  7. <?php
  8. endif;
  9. ?>
  10. <?php
  11. if(of_get_option('latest_video_tab', 'yes') == 'yes'):
  12. ?>
  13. <li><a href="#latest"><?php echo of_get_option('latest_videos_tab_text', 'Latest Videos'); ?></a></li>
  14. <?php
  15. endif;
  16. ?>
  17. <?php
  18. if(of_get_option('recommended_vids', 'no') == 'yes'):
  19. ?>
  20. <li><a href="#recommendations"><?php echo of_get_option('recommended_tab_text', 'Recommendations'); ?></a></li>
  21. <?php
  22. endif;
  23. ?>
  24. <?php
  25. if(of_get_option('popular_vids', 'no') == 'yes'):
  26. ?>
  27. <li><a href="#popular"><?php echo of_get_option('popular_tab_text', 'Popular Videos'); ?></a></li>
  28. <?php
  29. endif;
  30. ?>
  31. <?php
  32. if(of_get_option('more_vids', 'no') == 'yes'):
  33. ?>
  34. <li><a href="#more"><?php echo of_get_option('more_vids_tab_text', 'More Videos'); ?></a></li>
  35. <?php
  36. endif;
  37. ?>
  38. <?php
  39. $args = array(
  40. 'post_type' => 'page',
  41. 'numberposts' => -1,
  42. 'post_status' => null,
  43. 'post_parent' => of_get_option('features_parent_page'),
  44. 'order' => 'ASC',
  45. 'orderby' => 'menu_order'
  46. );
  47. $slides = get_posts($args);
  48. if($slides):
  49. foreach($slides as $post): setup_postdata($post);
  50. $image_id = get_post_thumbnail_id();
  51. $image_url = wp_get_attachment_image_src($image_id, 'content-slider');
  52. ?>
  53. <li>
  54. <a href="#<?php
  55. $title = get_the_title();
  56. $loweredTitle = strtolower($title);
  57. echo str_replace(" ", "_", $loweredTitle);
  58. ?>"><?php the_title(); ?></a>
  59. </li>
  60. <?php endforeach; endif;?>

  61. <div class="clearfix"></div>
  62. </ul>



  63. <?php
  64. endwhile;
  65. ?>
  66. <?php
  67. if(of_get_option('homepage_content', 'yes') == 'yes'):
  68. ?>
  69. <div id="main">
  70. <?php rewind_posts(); ?>
  71. <?php

  72. if(have_posts())
  73. while(have_posts()):
  74. the_post();
  75. ?>
  76. <?php the_content(); ?>
  77. <?php
  78. endwhile;
  79. ?>
  80. <div class="home-page-older"></div>


  81. </div>

  82. <?php
  83. endif;
  84. ?>
  85. <?php
  86. if(of_get_option('latest_video_tab', 'yes') == 'yes'):
  87. ?>
  88. <div id="latest">
  89. <?php
  90. //fetch posts based on our taxonomy (for 'portfolio' custom post type)
  91. $tabbed_number_posts = of_get_option('tabbed_number_posts','24');
  92. $args = array(
  93. 'numberposts' => $tabbed_number_posts,
  94. 'post_type' => 'portfolio',
  95. 'post_type' => 'portfolio',
  96. 'tax_query' => array(
  97. array(
  98. 'taxonomy' => 'p_type',
  99. 'field' => 'slug',
  100. 'terms' => 'featured',
  101. 'operator' => 'NOT IN'
  102. )
  103. )
  104. );
  105. $featured_posts = get_posts($args);
  106. include 'tabbed-vids.php';
  107. ?>
  108. <div class="home-page-older"></div>
  109. </div>
  110. <?php
  111. endif;
  112. ?>
  113. <?php
  114. if(of_get_option('recommended_vids', 'yes') == 'yes'):
  115. ?>
  116. <div id="recommendations">
  117. <?php
  118. //fetch posts based on our taxonomy (for 'portfolio' custom post type)
  119. $tabbed_number_posts = of_get_option('tabbed_number_posts','24');
  120. //$portfolio_type = get_post_meta($post->ID, 'p_type', true);
  121. //echo '<br /> portfolio_type get post meta: '.$portfolio_type.'<br />';
  122. $args = array(
  123. 'numberposts' => $tabbed_number_posts,
  124. 'post_type' => 'portfolio',
  125. 'p_type' => 'recommended'
  126. );
  127. $featured_posts = get_posts($args);
  128. include 'tabbed-vids.php';
  129. ?>
  130. </div>

Hoffentlich reicht der Auszug.

Der Code lädt einen Content in einen DIV Container. Oben ist im DIV Container eine Navigation, darunter wird der jeweilige Text eingeblendet, je nach dem, auf welchen Menüpunkt geklickt wird.

Mein Problem ist aber, dass ich den DIV in dem das Menü ist, schließen will und den Inhalt in einen neuen Div Conteiner laden möchte. Mache ich das, klappt das Skript nicht mehr.

Hättet ihr eine Idee, was mach anpassen könnte oder wo ich ansetzen sollte?

lg
 
Ich glaube du solltest den Code nochmal posten in den code tags und ohne Zeilennummer. So bekommt man wenig Lust sich den Quellcode anzuschauen.

Die PHP Tags sind [PHP] PHP CODE [/PHP]

Edit: Na mich Spicelab extra drauf hingewiesen hat, habs ich mal geändert :D
 
Zuletzt bearbeitet:
Hallo,

mach ich gerne. :)

PHP:
<div class="tabs">

               <ul class="tabNavigation">

                    <?php
                        if(of_get_option('homepage_content', 'yes') == 'yes'):
                   ?>

                    <li><a href="#main"><?php the_title(); ?></a></li>

                    <?php
                        endif;
                    ?>

                    <?php
                        if(of_get_option('latest_video_tab', 'yes') == 'yes'):
                    ?>

                   <li><a href="#latest"><?php echo of_get_option('latest_videos_tab_text', 'Latest Videos'); ?></a></li>

                    <?php
                        endif;
                    ?>

                    <?php
                        if(of_get_option('recommended_vids', 'no') == 'yes'):
                    ?>

                            <li><a href="#recommendations"><?php echo of_get_option('recommended_tab_text', 'Recommendations'); ?></a></li>

                    <?php
                        endif;
                    ?>

                    <?php
                        if(of_get_option('popular_vids', 'no') == 'yes'):
                    ?>

                   <li><a href="#popular"><?php echo of_get_option('popular_tab_text', 'Popular Videos'); ?></a></li>

                    <?php
                        endif;
                    ?>

                    <?php
                        if(of_get_option('more_vids', 'no') == 'yes'):
                    ?>

                   <li><a href="#more"><?php echo of_get_option('more_vids_tab_text', 'More Videos'); ?></a></li>

                    <?php
                        endif;
                    ?>

                        <?php
                        $args = array(
                            'post_type' => 'page',
                            'numberposts' => -1,
                            'post_status' => null,
                            'post_parent' => of_get_option('features_parent_page'),
                           'order' => 'ASC',
                           'orderby' => 'menu_order'
                        );
                        $slides = get_posts($args);
                        if($slides):
                            foreach($slides as $post): setup_postdata($post);
                                $image_id = get_post_thumbnail_id();
                                $image_url = wp_get_attachment_image_src($image_id, 'content-slider');
                        ?>
                        <li>
                            <a href="#<?php
                            $title = get_the_title();
                            $loweredTitle = strtolower($title);
                            echo str_replace(" ", "_", $loweredTitle);
                            ?>"><?php the_title(); ?></a>
                        </li>
                        <?php endforeach; endif;?>
     
                    <div class="clearfix"></div>
               </ul>

                <?php
                            endwhile;
                        ?>
              
                <?php
                    if(of_get_option('homepage_content', 'yes') == 'yes'):
                ?>
      
                <div id="main">
                    <?php rewind_posts(); ?>
                        <?php

                                if(have_posts())
                                    while(have_posts()):
                                        the_post();
                            ?>
                              
                    <?php the_content(); ?>
                       
                    <?php
                                endwhile;
                            ?>
          
                    <div class="home-page-older"></div>

               </div>

                <?php
                            endif;
                        ?>
                
                <?php
                    if(of_get_option('latest_video_tab', 'yes') == 'yes'):
                ?>

               <div id="latest">
                    <?php
                        //fetch posts based on our taxonomy  (for 'portfolio' custom post type)
                        $tabbed_number_posts = of_get_option('tabbed_number_posts','24');
              
                        $args = array(
                                    'numberposts' => $tabbed_number_posts,
                                    'post_type' => 'portfolio',
                                    'post_type' => 'portfolio',
                                        'tax_query' => array(
                                            array(
                                                'taxonomy' => 'p_type',
                                                'field' => 'slug',
                                                'terms' => 'featured',
                                                'operator' => 'NOT IN'
                                            )
                                        )
                                    );
                          
                              
                        $featured_posts = get_posts($args);
              
                        include 'tabbed-vids.php';
                    ?>
                              
                                  <div class="home-page-older"></div>
          
               </div>
                <?php
                            endif;
                        ?>
              
                <?php
                        if(of_get_option('recommended_vids', 'yes') == 'yes'):
                ?>
                            <div id="recommendations">
                                    <?php
                                        //fetch posts based on our taxonomy  (for 'portfolio' custom post type)
                                        $tabbed_number_posts = of_get_option('tabbed_number_posts','24');
                              
                                        //$portfolio_type = get_post_meta($post->ID, 'p_type', true);
                                        //echo '<br /> portfolio_type get post meta: '.$portfolio_type.'<br />';
                              
                                        $args = array(
                                                    'numberposts' => $tabbed_number_posts,
                                                    'post_type' => 'portfolio',
                                                    'p_type' => 'recommended'
                                                    );
                                                  
                                        $featured_posts = get_posts($args);
                              
                                        include 'tabbed-vids.php';
                                    ?>
                                      
                                </div>
                <?php
                        endif;
                ?>

Im Anhang habe ich gezeichnet, wie ich den Code gerne umschreiben würde. Jetzt ist es so, wenn ich die DIVS so setze, wie gezeichnet, lädt der Content im unteren Container nicht mehr, ich muss also die Navigation und den unteren Content im selben DIV belassen.

lg
 

Anhänge

  • Nav + Content.jpg
    Nav + Content.jpg
    126,1 KB · Aufrufe: 8
Zuletzt bearbeitet:
Zurück
Oben