WordPress.org

Ready to get started?Download WordPress

Forums

Multiple content blocks
[resolved] query_posts and similar functions breaking v3.01 (3 posts)

  1. emati
    Member
    Posted 1 year ago #

    Hello,

    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

    <?php
    //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/front.page.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">
    	<ul>
    	<?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; ?>
    		</li>
    	<?php endforeach; ?>
    	</ul>
    </div>
    <div class="main-slider-shadow"><img src="<?php echo get_bloginfo( 'template_directory' ); ?>/images/mainslider-shadow.png" alt="" /></div>
    
    <div id="teasers">
    	<ul>
    		<li><?php the_block("Teaser First"); ?></li>
    		<li><?php the_block("Teaser Second"); ?></li>
    		<li><?php the_block("Teaser Third"); ?></li>
    	</ul>
    </div>
    
    <?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!

    http://wordpress.org/extend/plugins/multiple-content-blocks/

  2. emati
    Member
    Posted 1 year ago #

    Ok, i found out that i can't use $post variable in any foreach loop or any other.

    Sorry for trouble.

  3. Trendwerk
    Member
    Plugin Author

    Posted 1 year ago #

    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).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.