I had tried using || is_page( 238 ) || is_page( 239 ) in the code but when I do it and add the code to the child-theme functions file the site breaks (so I must be doing something badly). I also created a child them inc/extras.php file
Currently in my functions.php child theme file is the following code that I use to disable the captions on the slider
<?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('sparkling-style');
wp_enqueue_style( 'sparkling-style',
get_stylesheet_directory_uri() . '/style.css',
array('parent-style')
);
}
/**
* Featured image slider, displayed on front page for static page and blog
*/
function sparkling_featured_slider() {
if ( is_front_page() || is_page( 238 ) || is_page( 239 ) && of_get_option( 'sparkling_slider_checkbox' ) == 1 ) {
echo '';
echo '<ul>';
$count = of_get_option( 'sparkling_slide_number' );
$slidecat =of_get_option( 'sparkling_slide_categories' );
$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 ( (function_exists( 'has_post_thumbnail' )) && ( has_post_thumbnail() ) ) :
echo get_the_post_thumbnail();
endif;
echo '';
if ( get_the_title() != '' ) echo ''. get_the_title().'';
if ( get_the_excerpt() != '' ) echo '' . get_the_excerpt() .'';
echo '</div>';
echo '</li>';
endwhile;
endif;
echo '</ul>';
echo ' </div>';
}
}
is_page() || is_post() ) in case I was wrong with the page id’s but it still didn’t show.
I am using the right conditionals? One of the pages I am trying to get it to display on has this in the source: body class="home page-template-default page page-id-239" which I presume makes it page id 239.
( ( is_front_page() || is_page() ) works but not on the 2 pages I wanted it to work with those were the 2 additional translation pages of the homepage using WPML plugin.
Basically I wanted the slider to appear in the header area of the site.comsite.com/es and site.com/nl (2 languages es and nl)
Adding ( ( is_front_page() || is_page() ) to the child themes makes the slider appear on all site.com/pages but not the translated pages. Is there conditionals to use for these pages?
the dev page is http://cab.brianharte.co.uk and you’ll see the slider is currently on ALL the english pages (default language) but not on either homepage spanish or dutch or the dutch About Us page. No other secondary language pages exist yet to test with.
It is working fine on my test site so could you please share me the page URLs from your site where it is not displaying correctly so that i can troubleshoot it?
the dev page is http://cab.brianharte.co.uk and you’ll see the slider is currently on ALL the english pages (default language) but not on either homepage spanish or dutch or the dutch About Us page. No other secondary language pages exist yet to test with.
This is because that plugin changes the home page URL to another page so please check whether that translator plugin provides any function to check whether the page is translated home page so that you can use it in the above code condition.
If it doesn’t provide then you can just display the slider on all pages by using the solution posted in the following reply.
Thanks. I posted on the WPML support forums and it appears I was missing one step from my actions to make it work. I know others have had similar issues so I wanted to post the fix below in case future people are also missing that same step…
Now go to every slide post and duplicate them in all languages.
Go to front-end and check the slider, it should work properly.
Basically, although I had translated the homepage PAGES in to the multiple languages I had not translated the taxonomy of post categories and neither the slider posts. Once that was done the slider showed in all languages.
I’ve removed is_page() from my child theme edits so that now it is back to where it should be with it showing on only the frontpages of all the languages.