0

Plugin used: Types

I have created posts with Custom Posts and the regular Posts by Wordpress. However, the custom posts does not appear on the website. Only the regular posts appears.

Here I have created Custom Posts: Custom Posts

Here I have created posts with the regular Wordpress posting: Wordpress Posts

Here are the 2 latest posts within the category 9 (Featured) supposed to be shown: 2 latest posts within the category 9

As you see, it does not show the one made with Custom Post. This is not the only example, but this is the easiest one to explain.

Code

        <div class="col-md-12 myeluft">
            <?php
                $catquery = new WP_Query( 'cat=9&posts_per_page=2' );
                while($catquery->have_posts()) : $catquery->the_post();     
            ?>  
            <div class="featured-post">
                <ul>    
                    <li>
                        <div class="col-md-5 featuredimage myeluftned"> 
                            <?php the_post_thumbnail( 'singlepost-thumb' ); ?>
                        </div>
                        <div class="col-md-7 myeluftned">
                            <h2 class="nomargintop blacklink">
                                <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
                            </h2>
                            <div class="light offblack">
                                <?php the_content(); ?>
                            </div>
                            <a href="<?php the_permalink() ?>" rel="bookmark">
                                <button class="btn thin luft" type="button">Se prosjekt</button>
                            </a>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="col-md-12">
                <hr class="myeluft clearboth">
                <?php endwhile; ?>
            </div></div>

Anyone?

I will post detailed if you want, I just need to know what you want to know.

Is there a function I need to make Custom Fields Post to work?

Suggestions:

  • Functions.php, something is wrong here
  • Types, something is wrong the setup
5
  • Check if the post type publicly_queryable is set to true or false
    – Karun
    Jul 1 '15 at 13:16
  • Thank you. I can see a hook by publicly queryable, so I believe it means its set to true
    – Olen
    Jul 1 '15 at 13:33
  • @olen If a regular post have custom fields the post should be shown, even if the code for retreiving custom fields are not implemented. Custom fields and custom post type are different. On query you must query post_type="your-custom" if exist any different to normal post, and to retreive custom fields use the code $your-string = get_post_meta($post->ID, 'your-custom-field', true); Jul 1 '15 at 16:17
  • Exactly what "Custom Fields" created the posts? Plugin? What? And exactly what does it do?
    – s_ha_dum
    Jul 1 '15 at 19:49
  • Thanks for commenting. I will update the post right now.
    – Olen
    Jul 1 '15 at 20:03
0

The problem was solved by making it display all post types:

$args = array(
    'cat' => 9,
    'posts_per_page' => 2,
    'post_type' => 'any',
);
new WP_Query($args);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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