• <?php
    while( $query->have_posts() ): $query->the_post();
    $metadata = get_metadata( 'post', get_the_ID() );
    $background_image = '';
    
    $image_url = array( '', '' );
    
    $image_id         = get_post_thumbnail_id();
    $image_url        = wp_get_attachment_image_src( $image_id, 'full', true );
    $background_image = 'background-image: url(' . $image_url[0] . ');';
    
    ?>
    
    <div id='sliders-container' style="background-position: 50% 50%; background-repeat: no-repeat;max-width: 100%;height: 600px; <?php echo $background_image; ?>">
    </div>
    
    <?php endwhile;
    wp_reset_query();
    ?>

    This code don’t work, someone have a solution ??

    Thanks you

Viewing 9 replies - 1 through 9 (of 9 total)
  • What is the exact error message? I don’t see any code that sets $query in your snippet; how are you defining that variable?

    Thread Starter 1kan5

    (@1kan5)

    sorry, I am very noob and my english is poor (I’m french)

    i try this code

    <?php
    
    			$query = new WP_Query( $args );
    
    while( $query->have_posts() ): $query->the_post();
    $metadata = get_metadata( 'post', get_the_ID() );
    $background_image = '';
    
    $image_url = array( '', '' );
    
    $image_id         = get_post_thumbnail_id();
    $image_url        = wp_get_attachment_image_src( $image_id, 'full', true );
    $background_image = 'background-image: url(' . $image_url[0] . ');';
    
    ?>
    
    <div id='sliders-container' style="background-position: 50% 50%; background-repeat: no-repeat;max-width: 100%;height: 600px; <?php echo $background_image; ?>">
    </div>
    
    <?php endwhile;
    wp_reset_query();
    ?>

    but nothing appear

    I want to display the big image without “fusion slider”

    for example :

    http://www.espace-musculation.com/cheat-meals.html

    =>> http://www.espace-musculation.com/wp-content/uploads/2015/10/cheat-meals.jpg

    After this line:

    $background_image = 'background-image: url(' . $image_url[0] . ');';

    can you temporarily add this line:

    var_dump( $background_image );

    On your site, you should see a line that looks something like this:

    string(96) "background-image: url(http://localhost.dev/wordpress/wp-content/uploads/2012/01/cityscape.jpeg);"

    (Don’t worry, this line will go away once we remove the code. I just want to see if $background_image is being set properly.) Do you see any text like that on your site?

    Thread Starter 1kan5

    (@1kan5)

    I try to add the line

    <?php
    
    $query = new WP_Query( $args );
    
    while( $query->have_posts() ): $query->the_post();
    $metadata = get_metadata( 'post', get_the_ID() );
    $background_image = '';
    
    $image_url = array( '', '' );
    
    $image_id         = get_post_thumbnail_id();
    $image_url        = wp_get_attachment_image_src( $image_id, 'full', true );
    $background_image = 'background-image: url(' . $image_url[0] . ');';
    var_dump( $background_image );
    ?>
    
    <div id='sliders-container' style="background-position: 50% 50%; background-repeat: no-repeat;max-width: 100%;height: 600px; <?php echo $background_image; ?>">
    </div>
    
    <?php endwhile;
    wp_reset_query();
    ?>

    but nothing appear

    Thread Starter 1kan5

    (@1kan5)

    For help, Here the original file :

    It is for a slider but i want to show the unique image without slider.

    [ Massive code block deleted ]

    If you’re not seeing anything, it means that $background_image isn’t being set properly. Do the posts that you’re fetching have featured images set? I don’t see any code that sets $args in your snippet; how are you defining that variable?

    Thread Starter 1kan5

    (@1kan5)

    You are very nice 🙂 thanks you.

    I try to add this :

    <?php
    
    function render_parent( $args, $content = '') {
    
    		global $smof_data;
    
    		$defaults = FusionCore_Plugin::set_shortcode_defaults(
    			array(
    				'class'			=> '',
    				'id'			=> '',
    				'name' 			=> '',
    			), $args
    		);	
    
    		extract( $defaults );
    
    		ob_start();
    
    		$term = $name;
    
    		$term_details = get_term_by( 'slug', $term, 'slide-page' );
    
    		$args				= array(
    			'post_type'		=> 'slide',
    			'posts_per_page'   => -1,
    			'suppress_filters' => 0
    		);
    		$args['tax_query'][] = array(
    			'taxonomy' => 'slide-page',
    			'field'	=> 'slug',
    			'terms'	=> $term
    		);
    }

    but nothing appear

    Is the snippet you just posted in the same file as the previous code snippets you’ve posted?

    Also, have you spoken with your theme’s author? They’re probably in a better position to help, as they know their code better than me.

    Thread Starter 1kan5

    (@1kan5)

    yes

    yes you right but they don’t get support for this 🙁

    (thanks you Avada support)

    i will try some thing else, thanks you for your help Stephen 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Something wrong ?’ is closed to new replies.