Support » Plugin: More Types » [Plugin: More Types] How to show more types with template

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello. Just a quick reply. Once you have created your new POST TYPE using the plugin, you need to go into one of your template files (for example I create a brand new template and only used the following code inside of it).

    <?php
    $args = array(
    		'post_type' => 'ourevent',
    		'posts_per_page' => -1
    );
    
    $posts = get_posts($args);
    foreach ( $posts as $post )
    {
           setup_postdata($post); ?>
           <a href="<?php the_permalink(); ?>">
           <h3>"<?php the_title();?>"</h3></a>
    } ?>

    Basically, you build an argument where your ‘post_type’ is set to the type you are looking for (replace ‘ourevent’ with the name of your type)

    We then make a new variable with that data (I called mine $posts) we are then calling ‘get_posts’ to get ALL of the posts with that type.

    Then you need to ‘setup_postdata’ as I have above and then simply print out the data from each post as you need it. In my example I have just printed out the title and made a link to the article.

    I hope this helps!

    I just can’t get this to work. I copied your file, above, as a template and tried many different things.

    I have two custom fields. FirstName and LastName. Could you please provide an example of a working post template?

    Thanks!

    Mike

    Hey Mate,

    Ok well I don’t use this plugin any more (I use ‘Custom Content Type Manager’ which is amazing for creating my own ‘Types’) but ill see if I can help you out anyway.

    Can you copy and paste your entire page template file? It should look something similar to this:

    <?php
    /**
    Template Name: OurEvents
    */

    get_header();

    /*Build an array variable to hold ALL of our event data */
    /*Change the ‘ourevent’ to your custom post type*/
    $args = array(
    ‘post_type’ => ‘ourevent’,
    ‘posts_per_page’ => -1
    );

    /*Get all the posts */
    $posts = get_posts($args);

    /*Loop through all of the posts in the custom post type*/
    foreach ( $posts as $post )
    {
    /*Set up the post data */
    setup_postdata($post); ?>
    <h3>”<?php the_title();?>”</h3>

    <!– we create a variable and capture the ‘EventLocation’ in it, change this to the NAME of your individual variables that your trying to capture –>
    <p>
    <?php $EventLocation = get_post_meta($post->ID,’EventLocation’,true);
    echo $EventLocation ?>
    </p>

    <p>$EventDescription = get_post_meta($post->ID,’EventDescription’,true);
    echo $EventDescription ?></p>

    } ?>

    Wow, that looks like an awesome plugin and perhaps the things it does is appear to be the kinds of things I’m looking to do.

    I was using single.php from the Responsive theme. But before I start posting code and whatnot, I’m going to check out that plugin you’re using. It looks like it will do the trick.

    My first project with this is going to be a simple phone book. Seems like a good place to start.

    Thanks!

    Mike

    Yea that other plugin is probably the best I’ve used for content type management.

    I use that version, plus I’ve modified it for my own use too.

    It gets quite complex, but just read all of the documentation and information you can online and it should work well for you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: More Types] How to show more types with template’ is closed to new replies.