• Hello,

    I am wondering if it is possible to change a post to a different post type and ensure that the changed post still appears on the homepage. It seems, when I change the type it remains “published” but doesn’t appear there.

    Thanks in advance,

    Tim

Viewing 3 replies - 1 through 3 (of 3 total)
  • I believe that you would need to add a call to query_posts() and specify both ‘post’ and ‘your-post-type’ in the ‘post_type’ argument.

    The exact coding will depend on your theme.

    Thread Starter titan21

    (@titan21)

    Okay cheers – am not very familiar with the Codex although I am a dab hand at PHP. I am using the twentyeleven theme at the moment. Can someone dvise exactly what I should code and where?

    First, you must determine which template file is called. If you do not have a home.php file, it is probably index.php.

    If you are using the unmodified index.php from twentyeleven, try changing this:

    <div id="content" role="main">
    
    			<?php if ( have_posts() ) : ?>

    to this:

    <div id="content" role="main">
    
                            <?php
                            global $wp_query;
                            query_posts(
                                array_merge(
                                    $wp_query->query,
                                    array(
                                      'post_type' => array('post','my-custom-type')
                                    )
                                )
                            );
                            ?>
                            <?php if ( have_posts() ) : ?>

    Change ‘my-custom-type’ to your own type.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Posts’ is closed to new replies.