• Resolved Lada_sagitaria

    (@lada_sagitaria)


    Hey,
    First of all I’d like to thank you very much for the great theme Customizr!
    I am trying to set up Masterslider after header on main page of the site, and also I’d like to set up another one on the inner page https://terrasolutions.ru/?p=137. The rest of pages have to be without slider.
    Masterslider, which I need on home page the short code is [masterslider id=”10″], php call is <?php masterslider(10); ?>
    Masterslider, which I need on the page https://terrasolutions.ru/?p=137 the short code is [masterslider id=”13″], php call is <?php masterslider(13); ?>
    I did childify the theme, I wrote the code below in functions.php of my Baby Customizr, and failed.
    Your “Add some text after header” code snippet works perfectly though, you can see it on my main page.
    My functions.php code which does not work, made for main page only, not for inner page, just to test if main page slider works:

    <?php
    /* Write your awesome functions below */
    // Add some slider after the header at the homepage
    
    add_action( '__after_header' , 'master_slider' );
    function master_slider(){
     if ( !is_front_page() )
    return;
    
      <div> <?php echo do_shortcode('[masterslider id="10"]'); ?></div>
    <?php
    }

    Here is some info about the site:
    # SITE_URL: https://terrasolutions.ru
    # HOME_URL: https://terrasolutions.ru
    # IS MULTISITE : No

    # THEME | VERSION : Customizr | v3.3.12
    # WP VERSION : 4.1.1
    # PERMALINK STRUCTURE : /%postname%/

    # ACTIVE PLUGINS :
    Childify Me: 1.0.5
    Featured Pages Unlimited: 2.0.8
    Master Slider WP: 2.9.12
    Use Any Font: 4.3.1
    WordPress Font Customizer: 2.0.10
    WordPress SEO: 1.7.4

    PHP Version: 5.3.28
    MySQL Version: 5.5.35-33.0
    Web Server Info: Apache/2.2.15 (CentOS)

    WordPress Memory Limit: 40MB
    PHP Safe Mode: No
    PHP Memory Limit: 256M
    PHP Upload Max Size: 32M
    PHP Post Max Size: 32M
    PHP Upload Max Filesize: 32M
    PHP Time Limit: 30
    PHP Max Input Vars: 1000
    PHP Arg Separator: &
    PHP Allow URL File Open: Yes
    WP_DEBUG: Disabled

    Show On Front: page
    Page On Front: home (#2)
    Page For Posts: Блог (#56)

    Could you please help me to find out what is wrong?
    Thank you in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • try with:

    add_action( '__after_header' , 'print_master_slider', 1 );
    function print_master_slider(){
      $page_slider = array(
        //page_post_id => masterslider id;
        'home' => 10,
        '137'  => 13,
      );
      $master_slider_id = tc__f('__is_home') && array_key_exists('home', $page_slider) ? $page_slider['home'] : '';
      $master_slider_id = ( ! $master_slider_id && is_page() && array_key_exists(get_queried_object_id(), $page_slider ) ) ? $page_slider[get_queried_object_id()] : $master_slider_id;
    
      if ( ! $master_slider_id )
        return;
    
      echo do_shortcode('[masterslider id="'.$master_slider_id.'"]');
    }

    Thread Starter Lada_sagitaria

    (@lada_sagitaria)

    Oh My Goodness, it works!
    Thank you so much, d4z_c0nf!

    ?? Glad it helped.

    Hi,
    I have the same problem, except that I need only one slider, after header. Could you please help me modify the above code to have only one slider displaying. My slider id is 1. Thanks in advance!

    That code above displays just one slider, in home and with the slider id 1, if you replace this:

    $page_slider = array(
        //page_post_id => masterslider id;
        'home' => 10,
        '137'  => 13,
      );

    with this:

    $page_slider = array(
        //page_post_id => masterslider id;
        'home' => 1,
      );

    Hope this helps.

    Thank you very much for your help! I now have two sliders though. I used this code for functions.php:

    `add_action( ‘__after_header’ , ‘print_master_slider’, 1 );
    function print_master_slider(){
    $page_slider = array(
    //page_post_id => masterslider id;
    ‘home’ => 1,
    );
    $master_slider_id = tc__f(‘__is_home’) && array_key_exists(‘home’, $page_slider) ? $page_slider[‘home’] : ”;
    $master_slider_id = ( ! $master_slider_id && is_page() && array_key_exists(get_queried_object_id(), $page_slider ) ) ? $page_slider[get_queried_object_id()] : $master_slider_id;

    if ( ! $master_slider_id )
    return;
    echo do_shortcode(‘[masterslider id=”‘.$master_slider_id.'”]’);
    }

    Am I doing something wrong? My website: topdollardeal.com

    Ok, so I left the shortcode posted on my main page, thus the second slider. Removing the shortcode fixed the problem. How embarrassing =)
    Thanks a bunch for your help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Master Slider on homepage of Customizr only’ is closed to new replies.