Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ariimage

    (@ariimage)

    After an afternoon of searching I found this

    <?php
    echo '<div id="links" class="photographer-gallery">';
    
    <strong>
    // This replaces any spaces in the title with dashes
    $title_slug = strtolower(str_replace( " ", "-" , the_title_attribute('echo=0') ) );
    </strong>
    
    $args = array(
      'post_type' 	=> 'attachment',
      <strong>'category_name' => $title_slug,</strong>
      'numberposts' 	=> -1,
      'order'			=> 'rand',
      'post_status' 	=> null,
      'post_parent' 	=> null, // any parent
    );
    
    $attachments = get_posts($args);
     if ($attachments) {
     foreach ($attachments as $post) {
     setup_postdata($post);
     the_attachment_link($post->ID, false);
     }
    }
    
    echo '</div>';
    ?>

    [Moderator Note: Please post code & markup between backticks (not single quotes) or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Hope others find this usefull.

    Thread Starter ariimage

    (@ariimage)

    Ps you can see what I am working on.

    My Website

    Thread Starter ariimage

    (@ariimage)

    Fixed it. But cannot remember to post here and close topic.

    Im attempting something similar.

    $cat = array WP_Query('category_name='.wp_title());
    		$args = array(
    		    'post_type' => 'attachment',
    		    'category_name' => $cat,
    		    'numberposts' => -1,
    		    'post_status' => null,
    		    'post_parent' => null, // any parent
    		    );
    
    			$attachments = get_posts($args);
    			if ($attachments) {
    			    foreach ($attachments as $post) {
    			        // setup_postdata($post);
    			        the_attachment_link($post->ID, false);
    			        // the_excerpt();
    			    }
    			}

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    I am trying to get media and whittle it down to images for a category based on title.

    So if on the custom post for tony-irvine and media is category tony-irvine it shows only this and not any other media.

Viewing 4 replies - 1 through 4 (of 4 total)