• I am finding for any answers regarding with custom post type. I want to show its posts in my index file and yet it always redirect me to my single.php… Can someone help me how to this?.. or what code should i be applying in order to see my custom post in my index.php..

    Any responses will be much appreciated.. and besides I badly needed it.. thanks..

Viewing 12 replies - 1 through 12 (of 12 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    What do you want to do? Show only custom post type posts on the front page?
    https://codex.www.ads-software.com/Function_Reference/query_posts
    https://codex.www.ads-software.com/Function_Reference/WP_Query

    query_posts( 'post_type=myposttype' );

    Thread Starter shearamariz

    (@mariz_p)

    Thanks for the reply keesiemeijer.

    yes something like that.

    Thread Starter shearamariz

    (@mariz_p)

    query_posts( ‘post_type=myposttype’ );

    “myposttype” is this the title of my custom post type?.. thanks.. appreciated much your reply.

    Moderator keesiemeijer

    (@keesiemeijer)

    Yes replace “myposttype” with the name of the post type you registered.

    Thread Starter shearamariz

    (@mariz_p)

    This is my code.

    <div class="comment-area">
                        	<div class="comment-head">
                            	What We Do
                            </div>
                            <div class="clear"></div>
                            <div class="comment-pic">
                            	<img src="<?php bloginfo('template_url'); ?>/images/whatwedopic.png" title="what we do picture"  alt="what"/>
                            </div>
                            <div class="comment-context">
              <?php
    query_posts( 'post_type=movies' );
    ?>
    
                            </div>
                        </div>

    and yet it doesn’t show any of my post.. you could refer it with this link.. thanks.. https://getamiamitaxi.com/

    Thread Starter shearamariz

    (@mariz_p)

    the what we do title found on the left sidebar.. it actually doesn’t show any.. thanks..

    Moderator keesiemeijer

    (@keesiemeijer)

    Can you put the content of your index.php in a pastebin and link back to it here.
    How to post code in the pastebin: https://codex.www.ads-software.com/Forum_Welcome#Posting_Code

    Thread Starter shearamariz

    (@mariz_p)

    <!-- left content area -->
                    <div class="left-content-area">
    
                        <!-- What we do area -->
                        <div class="comment-area">
                        	<div class="comment-head">
                            	What We Do
                            </div>
                            <div class="clear"></div>
                            <div class="comment-pic">
                            	<img src="<?php bloginfo('template_url'); ?>/images/whatwedopic.png" title="what we do picture"  alt="what"/>
                            </div>
                            <div class="comment-context">
              <?php
    query_posts( 'post_type=movies' );
    ?>
    
                            </div>
                        </div>
                        <!-- //What we do area -->
    
                        <div class="clear"></div>
    
                        <div style="border-bottom:1px solid #c1c1c1; width:680px; margin:12px 8px 12px 8px;"></div>
    
                        <div class="clear"></div>
    
                        <!-- Order a taxi by call or text -->
                        <div class="comment-area">
                        	<div class="comment-head">
                            	Order a Taxi by Call or Text
                            </div>
                            <div class="clear"></div>
                            <div class="comment-pic">
                            	<img src="<?php bloginfo('template_url'); ?>/images/taxiorderpic.png" title="Order a Taxi by Call or Text picture"  alt="order"/>
                            </div>
                            <div class="comment-context">
                            	Lacus dictumst quis augue. Dolor placerat sed dolor nec aliquam ac tempor. Et et augue! Augue, nunc arcu enim natoque? Lectus, vel! Eu? Tincidunt. Tincidunt sit ac lorem, pid et dapibus amet mid. Dapibus dolor sagittis? Scelerisque ut risus mattis. Porta vel tincidunt sed, aenean. Facilisis nascetur tincidunt, massa, mauris eu magna enim mauris, lundium lundium a tempor rhoncus mid non habitasse, lacus elementum, urna placerat. Ut turpis nisi! Et? Porta aliquam sed lundium eros? Adipiscing, aliquet sed velit pulvinar, penatibus eu sed quis augue eros nascetur placerat integer, sit pena<br />Adipiscing vut dapibus. Integer urna sed ut scelerisque sit, a urna, dolor augue magnis urna diam dolor, et turpis, et duis risus! Et ut, lacus amet phasellus amet sed.
                            </div>
                        </div>
                        <!-- //Order a taxi by call or text -->
    
                    </div>
                    <!-- //left content area -->

    that is my code.. thanks

    Moderator keesiemeijer

    (@keesiemeijer)

    Please use the pastebin for large peaces of code.

    is this in your sidebar.php or index.php? I don’t see a loop in there.
    You can also do it with get_posts

    <?php
    $custom_posts = get_posts( 'post_type=movies' );
    foreach($custom_posts as $custom_post) : setup_postdata($custom_post); ?>
    	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    	<?php the_content(); ?>
    <?php endforeach; ?>

    `

    Thread Starter shearamariz

    (@mariz_p)

    It worked.. But my title of movies custom post type didn’t come out.. It still get the title of my default post. well anyways thank you so much.

    Moderator keesiemeijer

    (@keesiemeijer)

    It still get the title of my default post

    What do you mean by this?

    Thread Starter shearamariz

    (@mariz_p)

    This is the code:

    <iframe src=”https://pastebin.com/embed_iframe.php?i=iuhW0NE2&#8243; style=”border:none;width:100%”></iframe>

    the default post i’m referring to is the post menu. It has a default post of hello world and the code you had given me get it’s title instead of my custom post title. thanks. YOu can still refer on this site.

    https://getamiamitaxi.com/

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘I want to show my custom post type in my index or homepage file’ is closed to new replies.