I've looked everywhere for a solution, but have yet to find one. Here is the situation. I've created a custom content type using the plugin Custom Content Type Manager and now have need to use these custom post types within pages that I've created in WP.

So I created a page called "Photos" and use a template php file to configure the layout / styles of the page. The plugin generated a sample template for me in order to get the custom fields that I've put in. It looks something like this:

get_header(); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <h1><?php the_title(); ?></h1>
        <?php the_content(); ?>
        <?php the_author(); ?>

        <h2>Custom Fields</h2>  
        <strong>Image:</strong> <?php list($src, $w, $h) = get_custom_field('image:to_image_array');?>

        <img src="<?php print $src; ?>" height="<?php print $h; ?>" width="<?php print $w ?>" /><br />

<?php endwhile; // end of the loop. ?>

The Problem:

When I use "the_content();" and the other php methods, they pull the content from the page called "Photos", and not the content from the custom content type created with this plugin.

Is there something I can override / rewrite so that the_content(); from the custom content type shows up instead of the pages' content? Is there a better way I should be doing this other than creating WP pages and using custom templates? I am fairly new to this whole WP programming business..

2 Answers 2


The loop in your code is automatically going to pull data from the current page ID (i.e. Photos). You have to define the query for which data you're looking for. Be sure to replace photo with whatever the slug is for your post type.

See http://codex.wordpress.org/Class_Reference/WP_Query for other arguments you can use in addition to post_type.


$query = new WP_Query( array( 'post_type' => 'photo' ) );

if ( $query->have_posts() ) :

    while ( $query->have_posts() ) : $query->the_post(); ?>

             <?php the_title(); ?>

    <?php endwhile;



I think what is happening here is that WP is noticing that your URL ends with "photos" and so it is structuring a query based on that. You don't want that. You need to set up your own query. This thread should give you an idea of how to structure your query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.