Forum Replies Created

Viewing 9 replies - 16 through 24 (of 24 total)
  • Thread Starter hatefulcrawdad

    (@hatefulcrawdad)

    Here is the code I’m using to get my custom post type and taxonomy. Does it look right?

    add_action('init', 'portfolio');
    function portfolio()
    {
      $labels = array(
        'name' => _x('Portfolio', 'post type general name'),
        'singular_name' => _x('Portfolio', 'post type singular name'),
        'add_new' => _x('Add New', 'project'),
        'add_new_item' => __('Add New Project'),
        'edit_item' => __('Edit Project'),
        'new_item' => __('New Project'),
        'view_item' => __('View Project'),
        'search_items' => __('Search Projects'),
        'not_found' =>  __('No projects found'),
        'not_found_in_trash' => __('No projects found in Trash'),
        'parent_item_colon' => ''
      );
      $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => 4,
    	'_builtin' => false,
        'supports' => array('title','editor','thumbnail','custom-fields','cats')
      );
      register_post_type('portfolio',$args);
    }
    
    register_taxonomy( 'media', 'portfolio', array( 'hierarchical' => false, 'label' => __('Media Type'), 'query_var' => 'media' ) );

    Here is the code I’m using in my page file to try and get the ‘media’ => ‘print’ to pass through.

    <?php query_posts( array( 'post_type' => 'portfolio', 'media' => 'print' ) );
    while (have_posts() ) : the_post(); ?>
    
    <h2><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <?php endwhile; ?>
    Thread Starter hatefulcrawdad

    (@hatefulcrawdad)

    I cannot seem to get that to work. I wonder if my custom post code is wrong somewhere. Can you tell me how you went about creating your custom post? Did you use a plugin or go into function.php?

    Thread Starter hatefulcrawdad

    (@hatefulcrawdad)

    should 'post_type' => 'portfolio', 'Project Type' => 'Print' work?

    Thread Starter hatefulcrawdad

    (@hatefulcrawdad)

    That plugin doesn’t really do what I need. I just want to show posts that include the taxonomy “web” or something like that. But these posts are from a custom post type. It must be possible, why would WP leave that out?

    Thread Starter hatefulcrawdad

    (@hatefulcrawdad)

    I realize it going to take some programming skills. I just want en explanation of terms or tags that will filter by category of a custom post type.

    I’m currently using this code to pull out all posts in the “portfolio” post type. But I want to limit what it shows to the Project Type of ‘print’ or ‘web’, etc.

    <?php $port = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => 1 ) );
    while ( $port->have_posts() ) : $port->the_post(); ?>
    
      <h2><?php the_title(); ?></h2>
    
      <?php the_content(); ?>
    
    <?php endwhile; ?>
    Thread Starter hatefulcrawdad

    (@hatefulcrawdad)

    The more I look at it and fool around, the more it gets screwy. Shouldn’t there be a way to either push the rel though in the $args array? Or to echo the a tag and rel, then use the get attachment url? When I try that, it seems to break. Any help will be greatly appreciated.

    Thread Starter hatefulcrawdad

    (@hatefulcrawdad)

    oops, the code is actually this… I forgot to take out my attempt at adding rel to it.

    ?php
    $args = array(
    	'order'          => 'ASC',
    	'post_type'      => 'attachment',
    	'post_parent'    => $post->ID,
    	'post_mime_type' => 'image',
    	'post_status'    => null,
    	'numberposts'    => -1,
    );
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ($attachments as $attachment) {
    		echo wp_get_attachment_link($attachment->ID, 'medium');
    	}
    }
    ?>
    Thread Starter hatefulcrawdad

    (@hatefulcrawdad)

    Have you tried looking for some sort of gallery plugin? Perhaps one that has it’s own upload?

    I have looked around, but most of them seem to be more advanced than what I’m looking for. I’m simply having a page where it just lists clickable thumbnails of all the photos in the Media library, well thats what I want to have. I know I could just make a post and past the url’s in it, but I wanted something easier. I figured WP would have something native for posting things from the media library, strange that it doesn’t.

    For now I suppose I can just upload the images to blog posts as the method of uploading so that it will work. But I also don’t want to have to show a bunch of images with a blog if I want to upload pics from a trip or something.

    Thread Starter hatefulcrawdad

    (@hatefulcrawdad)

    so by “attached” you mean they would have to be part of a blog post? They can’t just be images that I upload straight into the Media Library?

Viewing 9 replies - 16 through 24 (of 24 total)