• 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 with a 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 with a page

This topic is: resolved

Tagged: custom post types, shortcodes

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

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

    It should display:
    Post title as link
    Meta data
    part of post with more link
    custom fields
    See: http://www.octoberstone.co.uk/wordpress/tenders/

    I have tried using a page template but it displays the list without the other page content - See: http://www.octoberstone.co.uk/wordpress/procurement/tenders-list/

    I've also tried shortcode (See - http://www.octoberstone.co.uk/wordpress/procurement/tenders-shortcode/). I am not very good at php and so I'm failing miserably to configure correctly.

    My theme is a child theme created from the Genesis theme. I would really appreciate any assistance or pointers.

    http://www.octoberstone.co.uk/wordpress/tenders/
    December 12, 2014 at 7:47 am #134367
    Brad Dalton
    Participant

    You could create a new WP_Query

    http://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters

    And then create a shortcode with the function.


    Tutorials for StudioPress Themes & WooCommerce.

    December 12, 2014 at 12:03 pm #134396
    DTHkelly
    Member

    Some non-coding options:
    https://wordpress.org/plugins/custom-content-shortcode/

    or Content Views
    Free
    https://wordpress.org/plugins/content-views-query-and-display-post-page/
    Premium
    http://www.contentviewspro.com/pricing/?utm_source=sample

    January 27, 2015 at 4:50 am #138740
    octoberstone
    Member

    Many thanks for your suggestions. I tried your suggestion Braddalton but I got lost - however it did help me understand how things worked and so I was able to refine my search and found the following which worked. The short code to be placed in my page is [Tenders]

    I found it here: http://wpsmith.net/2011/custom-post-types/understanding-wordpress-custom-post-types-displaying-custom-post-types/

    [PHP]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 .= '<header class="entry-header"><h3 class="tender-title">'.get_the_title() .'</h3></header>';
    $output .= '<p class="entry-meta">Published: <time class="entry-time" itemprop="datePublished">';
    $output .= get_the_date();
    $output .= '</time></p>';
    $output .= '<p>' .get_the_excerpt();
    $output .= '</p>';
    $output .= '<div class="tender-meta">';
    $output .= '

    • <span class="medium">Closing date: </span>' .get_field( 'closing_date' );
      $output .= '
    • <span class="medium">at </span>' .get_field( 'closing_time' );
      $output .= '

    ';
    $output .= '</div></div>';
    endwhile;
    }
    else
    $output = '<p>No tenders were found.</p>';
    $GLOBALS = $xglobals;
    return $output;
    }

    function my_init() {
    add_shortcode( 'tenders' , 'wps_tenders_posting' );
    }

    add_action('init' , 'my_init');
    [/PHP]

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Display custom post types with a 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