WordPress.org

Support

Support » Plugins and Hacks » Simple problem for someone who knows PHP and WordPress… $wp_query->query(

Simple problem for someone who knows PHP and WordPress… $wp_query->query(

  • 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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Andrew Nevins

    @anevins

    Forum moderator

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

    <?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();
    	}
    }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Simple problem for someone who knows PHP and WordPress… $wp_query->query(’ is closed to new replies.
Skip to toolbar