Support » Plugin: Multiple content blocks » query_posts and similar functions breaking v3.01

  • Resolved KrazyGuru



    I have used to use this plugin i almost every time when i get wordpress site to do, and when the latest version came i get wired bug. When i query posts by using query_posts function or get_posts (both functions are buging plugin) the_block functions are not working.

    My code

    //Template Name: Startseite
    // Load bxslider
    wp_enqueue_script('bxslider', '/wp-content/themes/loewegalerie/js/jquery.bxslider.js');
    wp_enqueue_script('front.application', '/wp-content/themes/loewegalerie/js/');
    wp_enqueue_style('bxslider', '/wp-content/themes/loewegalerie/js/jquery.bxslider.css'); 
    $config = array('post_type' => 'page', 'post_parent' => get_option('_wp_mainslider_post_id'));
    get_header(); ?>
    <div id="main-slider">
    	<?php foreach(get_posts($config) as $post): ?>
    		<li class="mainslider-item">
    			<?php $slide_image = get_post_meta( $post->ID, 'mcb-slide-image' ); ?>
    			<div class="slide-image"><?php echo $slide_image[0]; ?></div>
    			<?php if($post->post_content): ?>
    			<div class="slide-description"><p><?php echo apply_filters('the_content', $post->post_content); ?></p></div>
    			<?php endif; ?>
    	<?php endforeach; ?>
    <div class="main-slider-shadow"><img src="<?php echo get_bloginfo( 'template_directory' ); ?>/images/mainslider-shadow.png" alt="" /></div>
    <div id="teasers">
    		<li><?php the_block("Teaser First"); ?></li>
    		<li><?php the_block("Teaser Second"); ?></li>
    		<li><?php the_block("Teaser Third"); ?></li>
    <?php get_footer(); ?>

    When i remove get_posts or query_posts i have to refresh admin page twice to see my teaser blocks.

    Thanks in advice!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ok, i found out that i can’t use $post variable in any foreach loop or any other.

    Sorry for trouble.

    Plugin Author Trendwerk


    Yep. You’ll overwrite the actual $post if you do that. I advise you to use WP_Query for any custom loops (and use wp_reset_postdata to reset the data).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘query_posts and similar functions breaking v3.01’ is closed to new replies.