WordPress.org

Ready to get started?Download WordPress

Forums

custom post types and get_pages arguments dumb question (2 posts)

  1. Yukon Cornelius
    Member
    Posted 3 years ago #

    I am trying to pull content from my custom post type 'products' into my home page using get_pages()

    I am using the following code from the codex, but I must be doing something wrong with the arguments for get_pages because my posts aren't being pulled.

    Is this the right way to use the post_types argument?

    <?php
    	$mypages = get_pages('post_type=product');
    	$count = 0;
    	foreach($mypages as $page)
    	{
    		$content = $page->post_content;
    		if(!$content)
    			continue;
    		if($count >= 2)
    			break;
    		$count++;
    		$content = apply_filters('the_content', $content);
    	?>
    		<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
    		<div class="entry"><?php echo $content ?></div>
    	<?php
    	}
    ?>

    J

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic