• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Display custom post types on a genesis page

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Display custom post types on a genesis page

This topic is: resolved

Tagged: custom post types, Genesis child theme

  • This topic has 2 replies, 2 voices, and was last updated 8 years, 9 months ago by octoberstone.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • December 9, 2014 at 11:17 am #134090
    octoberstone
    Member

    I wish to display a list of custom post types (tenders) within the body of this page - http://www.octoberstone.co.uk/wordpress/procurement/tender-opportunities/

    I have created a page template and it lists the custom post types but the rest of the page content is not displayed. I'm not sure if using a page template is the correct approach. See - http://www.octoberstone.co.uk/wordpress/procurement/tenders-list/

    My child theme is put together from the Genesis theme. I have tried many ways from what snippets picked up but none are working correctly form me.

    I'm a learner, not very familiar with php and have built this from code snippets from many forums. I would really appreciate any assistance.

    Thanks. Tony

    http://www.octoberstone.co.uk/wordpress/procurement/tender-opportunities
    December 10, 2014 at 10:47 am #134199
    anotherusername
    Participant

    Hi Tony:

    Just a heads up: It looks like you marked this topic as resolved, which means that most people are going to think that yoiu already have a solution for this problem.

    If you are still seeking a solution, then you should make sure this thread is NOT marked as resolved.

    Unless you DID find a solution already, in which case you should post your solution here.

    December 10, 2014 at 11:04 am #134203
    octoberstone
    Member

    Thanks @anotherusername I mistaking published this topic twice. Couldn't figure out how to remove. 🙂
    I'm a beginner.

    I managed to figure out the code I required with trial and error. If anyone has a similar issue, this is what worked for me.
    I would be keen to know if the code is clean and is a good solution.

    My custom post type is 'tenders'
    I put the code below into my functions file (I actually created a function plugin)
    Thanks to http://wpsmith.net/2011/custom-post-types/understanding-wordpress-custom-post-types-displaying-custom-post-types/

    function wps_tenders_posting() {
    global $post;
    $xglobals = $GLOBALS;
    $args = array( 'post_type' => 'tenders' , 'posts_per_page' => 10 , 'orderby' => 'post_title' , 'order' => 'ASC' );
    $tendersloop = new WP_Query( $args );
    if ( $tendersloop->have_posts() ) {
    while ( $tendersloop->have_posts() ): $tendersloop->the_post();
    $output .= '<div id="tenders-content">';
    $output .= '&lt;header class="entry-header"&gt;&lt;h1 class="entry-title"&gt;<a href="'.get_permalink().'" title="' . get_the_title() . '">'.get_the_title() .'</a>&lt;/h1&gt;&lt;/header&gt;';
    $output .= '&lt;p class="entry-meta"&gt;Published: &lt;time class="entry-time" datetime="2014-11-10T10:47:44+00:00" itemprop="datePublished"&gt;';
    $output .= get_the_date();
    $output .= '&lt;/time&gt;&lt;/p&gt;';
    $output .= '&lt;p&gt;' .get_the_excerpt();
    $output .= '&lt;/p&gt;';
    $output .= '&lt;div class="tender-meta"&gt;';
    $output .= '<ul><li>&lt;span class="medium"&gt;Closing date: &lt;/span&gt;' .get_field( 'closing_date' );
    $output .= '<li>&lt;span class="medium"&gt;at &lt;/span&gt;' .get_field( 'closing_time' );
    $output .= '</li></ul>';
    $output .= '&lt;/div&gt;&lt;/div&gt;';
    endwhile;
    }
    else
    $output = '&lt;p&gt;No tenders were found.&lt;/p&gt;';
    $GLOBALS = $xglobals;
    return $output;
    }
    
    function my_init() {
    add_shortcode( 'tenders' , 'wps_tenders_posting' );
    }
    
    add_action('init' , 'my_init');
    
  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Display custom post types on a genesis page’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble