• Resolved ariimage

    (@ariimage)


    I have created a gallery and finally got it working. I am looking to add media images to each profile using the person title to call the category name.

    I saw this and cannot find the right way to get it to work.

    The gallery works using this:

    ‘<?php
    echo ‘<div id=”links” class=”galleries links”>’;
    $args = array(
    ‘post_type’ => ‘attachment’,
    ‘numberposts’ => -1,
    ‘order’ => ‘DESC’,
    ‘category_name’ => ‘galleries’,
    ‘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>’;
    ?>’

    Im trying to get this to work in it:

    $catname = array( ‘category_name’ = wp_title() );

    Can anyone help me

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

    (@ariimage)

    Ps you can see what I am working on.

    My Website

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Calling Title as Category in array’ is closed to new replies.