WordPress.org

Ready to get started?Download WordPress

Forums

Simple problem for someone who knows PHP and WordPress... $wp_query->query( (3 posts)

  1. tilleyt88
    Member
    Posted 10 months ago #

    Hi,

    So I'm pretty sure someone who knows PHP and WordPress can solve this for me quite quickly...hopefully :)

    So I have a custom post type in wordpress and I'm trying to display a list of posts that are in that custom type and custom post taxonomy.

    This is what I have so far...

    <?php
    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=5&post_type=custom-post-name'.'&paged='.$paged);
    while ($wp_query->have_posts()) : $wp_query->the_post();
    ?>

    Hope someone can help me with this.

    Much appreciated, Terry

  2. Andrew Nevins
    Barrel Rider, Spam Zapper & Volunteer Moderator
    Posted 10 months ago #

    What is your issue?
    Are you receiving any PHP errors?

  3. pdobariya
    Member
    Posted 10 months ago #

    <?php
    $args = array( 'post_type' => 'custom-post-name');
    $attachments = get_posts( $args );
    if ($attachments) {
    	foreach ( $attachments as $post ) {
    		setup_postdata($post);
    		the_title();
    		the_attachment_link($post->ID, false);
    		the_excerpt();
    	}
    }
    ?>

Reply

You must log in to post.

About this Topic