WordPress.org

Ready to get started?Download WordPress

Forums

Custom Gallery Rendering in WP 3.5 order problem (3 posts)

  1. DrSynonym
    Member
    Posted 1 year ago #

    I'm using this code to display attachments to a post in a custom gallery on a couple of sites.

    <?php
    $the_cat = get_the_category();
    $category_name = $the_cat[0]->cat_name;
    $category_description = $the_cat[0]->category_description;
    $category_link = get_category_link( $the_cat[0]->cat_ID );
    $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    
    	echo '<div class="titleblock-2"><p>';
    	echo customTitle(50);
    	echo '</p></div>';
    
    	$attachments = get_posts(array
    		(
    		'post_type' => 'attachment',
    		'numberposts' => -1,
    		'post_status' => 'published',
    		'post_parent' => $post->ID,
    		'orderby' => 'post__in',
    		'order' => ''
    		)
    	);
    
    	if ( $attachments ) {
    		echo '<div id="singlegallery">';
    		foreach ( $attachments as $attachment ) {
    			$attachment_page = get_attachment_link( $attachment->ID );
    			echo '<div class="big-thumb"><div class="gallery-icon"><a href="';
    			echo wp_get_attachment_url( $attachment->ID );
    			echo '">';
    
    			$myimage = preg_replace( '/(width|height)=\"\d*\"\s/', "", wp_get_attachment_image($attachment->ID, medium) ); echo $myimage; 
    
    			echo '</a></div></div>';
    			}
    		echo '</div>';
    		} 
    
    ?>

    It works, but in WP 3.5 but I can't re-order the images using the media upload tool. Changes are shown in the editor, and if I use the WP shortcode to render the gallery. Changes don't show in my custom gallery code though and that's the problem.

    For a variety of reasons I can't use the shortcode. All and any help appreciated.

  2. mdostanic
    Member
    Posted 1 year ago #

    In which file I can change it?

  3. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    @mdostanic - if you have a question, you'll get more help if you start a new thread and include more information in your post.

Topic Closed

This topic has been closed to new replies.

About this Topic