Jump to content
Sign in to follow this  
riomusi

Display Page Thumbnail, instead of Post Thumbnail in Carousel

Recommended Posts

riomusi

Hi, In the carousel section, I'd like to display the thumbnails of some child pages that belongs to one single parent page. I used the hook 'pagelines_carousel_list' by adding the following code in platformbase/functions.php (these code were modified from sections.carousel.php)

		add_action('pagelines_carousel_list', 'add_page_thumbnail');
	
		function add_page_thumbnail(){
			$args=array('child_of' => 28, 'numberposts' => $carouselitems);
			$recentposts = get_pages($args);
			foreach($recentposts as $cid => $c): ?>
	
			
				
					<?php if(has_post_thumbnail($c->ID)):
						echo get_the_post_thumbnail( $c->ID, array( $carousel_image_width, $carousel_image_height ),array( 'class' => 'list_thumb list-thumb' )); ?>
					<?php else: ?>
						
					<?php endif;?>
				<?php echo $c->post_title; ?>
				
			
	
			<?php endforeach;?>
		}
	[/code]

	
	I am sure that my get_pages function is getting the right pages. But I still get 'no thumb available' images only.
	
	Then I tried to look into platformpro/includes/core.init.php, in line 147:
	
	
[code] add_theme_support( 'post-thumbnails', apply_filters( 'pagelines_post-thumbnails', array('post') ) );
It seems the theme itself doesn't support 'page thumbnail'. Therefore, I added
	add_theme_support( 'post-thumbnails', array( 'page' ) );
	

Still no luck... I know I am close...Anyone can give me some hint? Thanks!

Share this post


Link to post
Share on other sites
[Deleted User]
Haven't really worked with that function myself, but you could try modifying this line: [code]$args=array('child_of' => 28, 'numberposts' => $carouselitems);[/code] so that it's: [code]$args=array('child_of' => 28, 'numberposts' => $carouselitems, 'post_type' => 'page');[/code]

Share this post


Link to post
Share on other sites
riomusi
Hello Iynnkate, I did dump the content of $recentposts, it gets those pages i want. Besides, the carousel thumbnail overlay did show those pages' title. So the problem must be here: [code] if(has_post_thumbnail($c->ID)) [/code] I've checked all my pages, they all have a attachement picture in its own gallery. How to define post_thumbnail in a post? Is that rule applies to pages also? Or the problem is in platformpro/includes/core.init.php? : [code] add_theme_support( 'post-thumbnails', apply_filters( 'pagelines_post-thumbnails', array('post') ) ); add_theme_support( 'post-thumbnails', array( 'page' ) ); [/code]

Share this post


Link to post
Share on other sites
Rob
First, PLEASE don't edit Core files. If you do and you update, they'll be overwritten and anything you've done will be gone. Secondarily, changes made to core files may have consequences you didn't anticipate in other areas. I strongly urge you to un-do what you've done in those files. Make sure this is present in platformbase/functions.php the following: [code]if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); }[/code] See http://codex.wordpress.org/Post_Thumbnails for more information.

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
[Deleted User]
While you shouldn't edit the core files, it is possible to copy those files over to your base installation and edit them there ;) @riomusi I hadn't looked at your code close enough :) I see now you were using "get_pages". Any update on the status?

Share this post


Link to post
Share on other sites
riomusi
Thanks @lynnkate, It works like a charm now!

Share this post


Link to post
Share on other sites
[Deleted User]
Awesome... Would you mind posting back with your solution? Someone in another thread was just asking this question and you might be able to help them out ;)

Share this post


Link to post
Share on other sites
riomusi
in functions.php , platformbase, add this: [code] if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } function add_page_thumbnail() { $args=array('child_of' => 28, 'numberposts' => $carouselitems, 'post_type' => 'page'); $recentposts = get_pages($args); foreach($recentposts as $cid => $c): ?>
  • ID)): echo get_the_post_thumbnail( $c->ID, array(100,75),array( 'class' => 'list_thumb list-thumb' )); ?> post_title; ?>

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    Sign in to follow this  

    ×