• Resolved hixen

    (@hixen)


    Hello everyone,

    Been trying to setup up my Custom Post Types, and so far i got pretty much everything working, except one little thing that I can’t manage to figure out.

    Is its possible to retrieve data from the singular_name in your custom post type and post it the loop?

    I got 2 Custom Post Types (Articles and Reports) in my query:

    <?php $my_query = new WP_Query( array( 'post_type' => array ('my-articles', 'my-reports'), 'showposts' => 10 ) ); ?>

    This works fine

    Now I wanted to add what type of post the post have, so I tried to do that with the following code:

    <?php
    $post_type = get_post_type( $post_id>ID );
    echo $post_type;
    ?>

    That gives me the following output: my-articles or my-reports.

    But thats not what I’m looking for, since I’m looking for the Output as in Article or Report (the singular_name)

    i tried this, but never got it working:

    <?php
    $post_type = get_post_type( $post_id>ID );
    $post_singular = array('$post_type' => array('labels' => 'singular_name'));
    echo $post_singular;
    ?>

    Don’t know if I’m on the right track, but I figured that I have to nestle my way in the arrays of this and get the data, but the lack of php-skills is in my way. So if anyone know a solution for this or can point me in the right way. (that is if this is the right way to handle stuff like that. I tend to make things more complicated then it have to be.)

    Sorry for my bad English, hope I made some kind of sense.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Custom Post Types and the Loop’ is closed to new replies.