Two Slider questions - Child Theme

Hey guys,

I have two questions about the editting of the child theme:

  1. What should I do when I want to display the slider on all sites not only the startpage?
  2. What should I do when I want to display the featured image of the pages instead of the posts?

Thank you in advance!

Sandro

Yes, I too am looking for instructions to add featured image directly below the purple menu bar with no space between:

https://colorlib.com/unite/shop/

Anyone has an idea?

Hi @coolicious,

I hope you are well today and thank you for your questions.

1. What should I do when I want to display the slider on all sites not only the startpage?

You can achieve this by using the child theme shared in the following topic.

https://colorlibsupport.com/t/how-to-make-slider-appear-on-every-page-using-child-theme-configurator-plugin/

2. What should I do when I want to display the featured image of the pages instead of the posts?

To achieve this please see the answer posted in the following topic for the similar question.

https://colorlibsupport.com/t/slider-for-pages-dazzling-theme/

Best Regards,
Movin

Hey Movin,

thank you for your answers.

Issue 1 is solved - thank you :slight_smile:

Issue 2 not :frowning:

The slider part of my functions.php looks now like this. I mixed the sparkling functions with my dazzling functions of the child themes but it doesnt work:

Can you may help me?

Could you please try using the below modified slider function?

/**
 * Featured image slider
 */
function dazzling_featured_slider() {
    if ( is_front_page() && of_get_option('dazzling_slider_checkbox') == 1 ) {
      echo '<div class="flexslider">';
        echo '<ul class="slides">';

          $count = of_get_option('dazzling_slide_number');
//          $slidecat = of_get_option('dazzling_slide_categories');

            if ( $count ) {
            $query = new WP_Query( array( 'posts_per_page' =>$count, 'post_type' => 'page', 'meta_key' => 'slider_page' ) );
//            print_r($query);
            if ($query->have_posts()) :
              while ($query->have_posts()) : $query->the_post();

              echo '<li>';
                if ( has_post_thumbnail() ) { // Check if the post has a featured image assigned to it.
                  the_post_thumbnail();
                }

                echo '<div class="flex-caption">';
                  echo '<a href="'. get_permalink() .'">';
                    if ( get_the_title() != '' ) echo '<h2 class="entry-title">'. get_the_title().'</h2>';
                    if ( get_the_excerpt() != '' ) echo '<div class="excerpt">' . get_the_excerpt() .'</div>';
                  echo '</a>';
                echo '</div>';

                endwhile;
              endif;

            } else {
                echo "Slider is not properly configured";
            }

            echo '</li>';
        echo '</ul>';
      echo ' </div>';
    }
}

Hey Movin,

thank you for your answer.
Unfortunately it is not. :confused:

Can it may be that I have to put in the following code into the functions.php?:

$query = new WP_Query( array( ‘cat’ => $slidecat, ‘posts_per_page’ => $count, ‘post_type’ => ‘page’, ‘slider_page’ => ‘yes’ ) );

In this thread you wrote that I have to make a custom field, therefore my question: https://colorlibsupport.com/t/slider-for-pages/

Yes you have to create slider_page custom field in the page and also set featured image to the page.

If still it is not working for you then could you please share me your child theme that contains this custom code so that i can troubleshoot it?

Yes, here is the functions.php :slight_smile:


<?php

// Queue parent style followed by child/customized style
add_action( 'wp_enqueue_scripts', 'func_enqueue_child_styles', 99);

function func_enqueue_child_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_dequeue_style('dazzling-style');
    wp_enqueue_style( 'dazzling-style',
        get_stylesheet_directory_uri() . '/style.css',
        array('parent-style')
    );
}

/**
 * Featured image slider
 */
function dazzling_featured_slider() {
    if ( of_get_option('dazzling_slider_checkbox') == 1 ) {
      echo '<div class="flexslider">';
        echo '<ul class="slides">';

          $count = of_get_option('dazzling_slide_number');
          $slidecat = of_get_option('dazzling_slide_categories');

            if ( $count && $slidecat ) {
            $query = new WP_Query( array( 'cat' => $slidecat, 'posts_per_page' => $count ) );
            if ($query->have_posts()) :
              while ($query->have_posts()) : $query->the_post();

              echo '<li>';
                if ( has_post_thumbnail() ) { // Check if the post has a featured image assigned to it.
                  the_post_thumbnail();
                }

                echo '<div class="flex-caption">';
                  echo '<a href="'. get_permalink() .'">';
                    if ( get_the_title() != '' ) echo '<h2 class="entry-title">'. get_the_title().'</h2>';
                    if ( get_the_excerpt() != '' ) echo '<div class="excerpt">' . get_the_excerpt() .'</div>';
                  echo '</a>';
                echo '</div>';

                endwhile;
              endif;

            } else {
                echo "Slider is not properly configured";
            }

            echo '</li>';
        echo '</ul>';
      echo ' </div>';
    }
}

/**
 * Enqueue scripts and styles.
 */
function custom_dazzling_scripts() {

  if( of_get_option('dazzling_slider_checkbox') == 1 ) {
  	wp_enqueue_style( 'flexslider-css', get_template_directory_uri().'/inc/css/flexslider.css' );
  }

  if(  of_get_option('dazzling_slider_checkbox') == 1 ) {
  	wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/inc/js/flexslider.min.js', array('jquery'), '2.2.2', true );
  }

}
add_action( 'wp_enqueue_scripts', 'custom_dazzling_scripts' );

Not just functions.php file. Could you please share me your whole child theme directory that contains this custom code so that i can troubleshoot it?

Ok, here are the ftp data:

Server: www286.your-server.de
User: neshat
PW: B5GLps8BbQtewWa9

You can find the page in “public_html” → “neshati” …

Thank you

Your shared site details are not working for me.

Could you please download the child theme directory from your sever that contains this custom code and share it to me so that i can troubleshoot it?

here it is :slight_smile:

I downloaded your shared child theme and made some changes in it to make the slider for pages work.

Could you please try using the attached updated child theme?

Unlike posts the pages don’t have category so you have to add ‘slider_page’ custom fields to the pages that you want to display in the slider as shown in the attached screenshot.

Hey Movin,

first of all thank you, but it doesnt work :confused:

this site should display a featured image but it doenst. I dont know why. I add the slider_page custom field

@coolicious I am not sure why it is not working on your site.

Would you mind if i log in to your site and do some troubleshooting? If this is ok then could you please share me your site log in details privately by checking the option “Set as private reply” when replying to this topic?

sure it is.

link: http://neshati.de.www286.your-server.de/neshati/
user: support_admin
passwort: PvI&T#!OjX%u@%9TEY!Y0xv9

Do you have some solutions for me? :confused: I rly need that slider soon :confused:

Thank you for sharing your site details.

I logged in to your site and made the slider for pages work on your site.

Could you please check it and let me know how it works for you?

Wow…thank you! :slight_smile:

  1. But, how I let the images display at the full width? Like now it isnt very nice :confused:
  2. How can I change the excerpt text? I dont want to display the full text of my page-content in the slider.

Thank you!!