• Resolved gavsiu

    (@gavsiu)


    im trying to dynamically write a bunch of stuff for a jquery plugin by pulling a list of attachments, but i cant seem to get it to sort by menu order. can someone take a look at this for me?

    i tried adding orderby menu_order but it ignores that.

    $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'audio', 'numberposts' => -1, 'post_status' => null, 'post_parent' => 8 );
    $attachments = get_posts( $args );
    if ($attachments) {
    	foreach ( $attachments as $post ) {
    		$url = wp_get_attachment_url($post->ID, false);
    		if ( substr( $url, -3, 3 ) == 'mp3' ) {
    			echo '{' . "\n" . 'name:"' . get_the_title() . '",' . "\n";
    			echo 'mp3:"' . $url . '",' . "\n";
    			echo 'mp3:"' . substr_replace( $url, 'ogg', -3, 3 ) . '"' . "\n" . '},' . "\n";
    		}
    	}
    }
  • The topic ‘sorting wp_get_attachment_url’ is closed to new replies.