• Resolved Fred Rocha

    (@johnfisherman)


    Here’s how you can adapt the Photo Galleria code to display a gallery also in pages and custom-type posts. The default behaviour applies only for regular posts.

    In the function were the javascript is added to the head, photo_galleria_scripts_head(), inside the file photo-galleria.php, add:

    /* also push pages into stack */
    	$pages = get_pages('numberposts=-1');
    
        foreach ($pages as $page) {
    			$pid = $page->ID;    
    
    			if ( stripos($page->post_content, '[gallery') !== false ) {
    				$element = "#galleria-" . $pid;
    				array_push($stack,$element);
    			}
    
        }
    
    	$args = array(
    		'post_type' => 'modalidades',
    	 );
    
     	// The Query
    	$the_query = new WP_Query( $args );
    
    	// The Loop
    	while ( $the_query->have_posts() ) : $the_query->the_post();
    
    		$pid = $post->ID;    
    
    		if ( stripos($post->post_content, '[gallery') !== false ) {
    			$element = "#galleria-" . $pid;
    			array_push($stack,$element);
    		}
    
    	endwhile;

    “modalidades” is the name of your custom type.

    Yes, it’s dirty. And yes, it works.

  • The topic ‘Photo Galleria broken for pages and custom types’ is closed to new replies.