• 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

Custom loop help needed

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 › Design Tips and Tricks › Custom loop help needed

This topic is: not resolved

Tagged: CPT Pagination, Custom fields, custom loop, genesis loop

  • This topic has 14 replies, 2 voices, and was last updated 8 years, 7 months ago by Brad Dalton.
Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • April 20, 2017 at 1:43 am #205041
    michaeloeser
    Member

    Hi,

    I have a (maybe simple) question: I need to create a custom loop for a CPT archive page. I already have the archive template (archive-marketplace.php) which currently uses the default loop. I need to change that in order to display some (custom)fields that are added by using ACF.

    I know there has a lot been written about custom loops but I can´t find a simple tutorial or example of such a custom loop.

    This is the CPT archive so far http://www.automotiveit.eu/marketplace

    Any support will be great.

    Thanks y´all
    Michael

    April 20, 2017 at 1:48 am #205043
    Brad Dalton
    Participant

    Which theme are you using?


    Tutorials for StudioPress Themes.

    April 20, 2017 at 1:53 am #205044
    michaeloeser
    Member

    It´s custom child theme based on the default Genesis theme. Nothing spectacular.

    April 20, 2017 at 3:57 am #205048
    Brad Dalton
    Participant

    For each entry?


    Tutorials for StudioPress Themes.

    April 20, 2017 at 4:16 am #205049
    michaeloeser
    Member

    I want to list the entries of that CPT marketplace on the archive page (http://www.automotiveit.eu/marketplace) in the form of showing several custom fields (like logo, some text etc.) as well as tags for each entry.

    A bit as shown in this screenshot (not exactly but similar)
    http://dl.dropbox.com/u/4814298/archive-IT4automotive.jpg

    So I need to modify the loop of the CPT marketplace archive page which currently uses the default loop.

    April 20, 2017 at 6:12 am #205055
    Brad Dalton
    Participant

    You want to output the custom field value in the entry for each post on the CPT archive?


    Tutorials for StudioPress Themes.

    April 20, 2017 at 6:41 am #205056
    michaeloeser
    Member

    Yes and some extra text possibly. Sounds like problem?

    April 20, 2017 at 7:08 am #205058
    Brad Dalton
    Participant

    Very simple. Use this tutorial

    2 Ways to use the code:

    1. You can change the hook to genesis_entry_content and remove the conditional then add the code directly to your template.

    Or

    2. Use the code in functions.php with a conditional tag for your archive type.

    Tested

    add_action( 'genesis_entry_content', 'michaeloeser', 13 );
    function michaeloeser() {
    $cf = get_post_meta( get_the_ID(), 'test', true );
    if ( ! empty( $cf ) ) {
    echo '<div class="text">'. $cf .'</div>';
        }
    }
    

    This code works with both the entry content and excerpt settings.


    Tutorials for StudioPress Themes.

    April 20, 2017 at 7:59 am #205059
    Brad Dalton
    Participant

    Full tutorial


    Tutorials for StudioPress Themes.

    April 20, 2017 at 8:11 am #205060
    michaeloeser
    Member

    Thanks. Will take a look at it

    April 21, 2017 at 4:01 am #205108
    michaeloeser
    Member

    Hey Brad,

    I figured everything out now except one simple thing. I created my own custom loop and that works. What currently not works is the default genesis page navigation at the end of a (archive) page. I´m talking about this "1,2,3...next page" navigation on the bottom of a default archive page (e.g http://www.automotiveit.eu/category/news) and I want to have that here as well: http://www.automotiveit.eu/marketplace

    Of course it can´t work because my loop doesn´t "know" about it and I assum I need to add it to my loop. But where can I find it how does it look? Is there a piece of code that I can add to my loop which outputs the default Genesis paging?

    Thanks
    Michael

    April 21, 2017 at 5:11 am #205110
    Brad Dalton
    Participant

    Hello Michael

    Works exactly the same for CPT loops.

    You'll need to check your posts per page settings as these affect all archive page types includes CPT archives unless overridden using code.

    If you have set posts per page to display 10 posts and you have 10 or less posts in the archive, pagination will NOT display as there's no more posts to paginate.

    You can override CPT archives using pre_get_posts.

    See updated tutorial.


    Tutorials for StudioPress Themes.

    April 21, 2017 at 5:56 am #205111
    Brad Dalton
    Participant

    Here's a video where i explain how to add custom fields to a custom post type archive page loop.

    Includes explanation about pagination.


    Tutorials for StudioPress Themes.

    April 28, 2017 at 3:02 am #205443
    michaeloeser
    Member

    Hi Brad,

    sorry for my late reply but I was quite busy in the last couple of days.

    My "problem" is I do not use the default Genesis loop at all. I use a custom loop. And by removing the default loop the pagination gets removed also

    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'dp_amtv_loop_archive_marketplace' );

    After that I go on with

    function dp_amtv_loop_archive_marketplace() { ?>
    
    <?php
    	// the query
    	$args = array(
    		'post_type' => 'marketplace',
    		'post_status' => 'publish',
    		'posts_per_page' => 10
    	);
    
    $the_query = new WP_Query( $args ); ?>
    
    <?php if ( $the_query->have_posts() ) : ?>
    
    	<!-- pagination here -->
    
    	<!-- the loop -->
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    		<!-- include the archive page output -->
    		<?php include( CHILD_DIR . '/inc/marketplace-stuff-archive.php' ); ?>
    
    	<?php endwhile; ?>
    	<!-- end of the loop -->
    
    	<!-- pagination here -->
    
    	<?php wp_reset_postdata(); ?>
    
    <?php else : ?>
    	<p><Nothing found...</p>
    <?php endif; ?>
    
    <?php }  // end function ?>

    I want the pagination where it says <!-- pagination here -->

    That´s why I mean there must be some kind of code snipped for that (hopefully)

    Any suggestions?

    Cheers
    Michael

    April 28, 2017 at 5:02 am #205447
    Brad Dalton
    Participant

    Did you see this tutorial.


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 15 posts - 1 through 15 (of 15 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 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