• I want to add a 2nd blog to my website, so I want the first blog to only show certain categories. This code will only show catacory ‘fotoblog’:

    $cat = ('fotoblog');
    
    $arguments = wp_parse_args( array(
        'orderby'           => 'date',
    'order'             => 'DESC',
    'posts_per_page'    => 10,
    'paged'             => $paged,
    'pagename'          => '', // reset page template to behave like archive
    'category_name'     =>  $cat,
    'extend'            => true
    ), $wp_query->query);

    So basically I was trying to use $cat variable as an array. But this isn’t working for me:

    $cat = array ("fotoblog", "name2", "name3");

    Any suggestions? Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    ariimage

    (@ariimage)

    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.

    esmi

    (@esmi)

    If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else’s topic.

    This 9 month old topic referencing an older version of WordPress is now closed.

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

The topic ‘WordPress category_name array for archive’ is closed to new replies.