Minimum Theme – How do I display custom post types on home page?

Community Forums Forums Design Tips and Tricks Minimum Theme – How do I display custom post types on home page?

This topic is: not resolved

This topic contains 2 replies, has 1 voice, and was last updated by  gmw 1 year, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2142

    gmw
    Participant

    On the Minimum theme demo home page, there are six posts displayed (title, excerpt, post date, etc.) with navigation buttons following. Instead of displaying blog post data I need to display custom post type data (title, date, location, price) for an events custom post type. If this is do-able, could you provide me with some pointers on how to proceed. Thanks!

    #2545

    gmw
    Participant

    I am able to create and update custom post types on the WP back-end and I can see all the data wp_postmeta via phpmyadmin. To display my CPT on the home page I modified home.php by commenting out the call to genesis_standard_loop(); I then created my own function gmw_events_loop();

    here is a snippet in my new function that I am having a problem with:

    $wp_query = new WP_Query( $args );
    while ( $wp_query->have_posts() ) : $wp_query->the_post();
    $meta = get_post_meta($post->ID, ‘gmw_events_meta’, true);

    (save the_title and meta data to array)

    endwhile;

    the_title (from wp_posts) returns the event name fine. My problem is that $post->ID is empty and therefore get_post_meta() returns nothing. If I hardcode the post_id into get_post_meta(), it works fine. It works in a simple theme I developed. I don’t know why it doesn’t work here. Any suggestions? Thx!

    • This reply was modified 1 year, 4 months ago by  gmw.
    • This reply was modified 1 year, 4 months ago by  gmw.
    • This reply was modified 1 year, 4 months ago by  gmw.
    • This reply was modified 1 year, 4 months ago by  gmw.
    • This reply was modified 1 year, 4 months ago by  gmw.
    • This reply was modified 1 year, 4 months ago by  gmw.
    #2557

    gmw
    Participant

    Never mind. I forgot to set global $post.

    A more important question would be is this a good way to accomplish my goal (displaying custom post types on home page). Honestly, I don’t know what I am doing here. I see all of these hooks and actions and wonder if there is a better way of accomplishing my goal and not building in problems down the road. Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.