• Resolved Susnos

    (@susnos)


    The issue can be found here: https://www.nunki.se
    The preview works: irrelevant
    It works with other themes: Haven’t Tried
    It works when I disable all other plugins: Haven’t Tried
    Meta Slider version: 3.6.8
    ———–
    Hi,
    I can not get MS to display slides on the static home page using the php function in our second language (which is English). The other pages works with multilingual languages but these are created with the shortcodes directly on the page.
    I have tried several variants with wordpress conditional both for slug ‘en’ and also for the page ID like:

    function sus_add_headerslider() { ?> 
    		<div class="slider-wrap">   
    		<?php if (is_front_page()) : echo do_shortcode("[metaslider id=27]");           
          elseif ( is_page( 833 )) : echo do_shortcode("[metaslider id=1040]");
          endif;
        ?>  
    		</div>  
    	<?php 
      }         
    add_action('thematic_belowheader','sus_add_headerslider');

    But looking on the source code does not change MS ID. But if I use the code below, (active on the site right now feb 4 2018) you’ll see in the source code that it retrieves the correct MS ID (which is 1040) but not the images in the ul class.

    function sus_add_headerslider() { ?> 
    		<div class="slider-wrap">   
    		<?php if (is_front_page()) {
        $curLang = substr(get_bloginfo( 'language' ), 0, 2);
        switch ($curLang) {
            case "en":
                // english slideshow for english users
                echo do_shortcode("[metaslider id=1040]");
                break;
            case "se":
            default:
                // fallback to swedish slideshow for any other language
                echo do_shortcode("[metaslider id=27]");
                break;
        }
    }
    ?>  
    		</div>  
    	<?php 
      }         
    add_action('thematic_belowheader','sus_add_headerslider');

    On this site, the slider should be just the same so I also tried to have the same MS ID (27) for both. Have also tested with the usual php function, but it does not work either. So the slider on the start page is only visible to the Swedish language.
    I would of course want it to appear on both languages.
    Anyone who has a solution?

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @susnos,

    Are the images on the slideshow saving properly?

    What happens if you switch 1040 and 27 around? Does it then only work on the English site?

    Thread Starter Susnos

    (@susnos)

    Thank you for your reply.
    I have now tested to switch and still the same problem, but you can se that the swedish site picks upp the MD ID 1040 and showing it.

    In the back end It looks like they are saveing properly, and otherwise they would not show in the swedish site now…

    Hi,

    I will have to look into this more. I’ll try to reproduce the error locally first. In the meantime, if you want to try to fix this, you can alter the file

    inc/slider/metaslider.class.php

    Look for the get_slides() function and in there you can alter the query. I’m thinking maybe one of these language arguments is causing a problem

    $args = array(
        'force_no_custom_order' => true,
        'orderby' => 'menu_order',
        'order' => 'ASC',
        'post_type' => array('attachment', 'ml-slide'),
        'post_status' => array('inherit', 'publish'),
        'lang' => '', // polylang, ingore language filter
        'suppress_filters' => 1, // wpml, ignore language filter
        'posts_per_page' => -1,
        'tax_query' => array(
            array(
                'taxonomy' => 'ml-slider',
                'field' => 'slug',
                'terms' => $this->id
            )
        )
    );

    Also, can you tell me which language plugin you are using? WPML?

    Thread Starter Susnos

    (@susnos)

    Yes I’m using WPML.
    Let me know if there is anything else you need.
    I will look into the function above, I’m no php ninja bu i’ll give it a try ??

    Hi,

    Well I think WPML is altering the query but I’m not sure exactly. The line 'suppress_filters' => 1 is supposed to stop that from happening.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘language 2 not visible using php function for front page’ is closed to new replies.