• 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

"Call to undefined function genesis_before_post()" errormessage

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 › "Call to undefined function genesis_before_post()" errormessage

This topic is: not resolved

Tagged: genesis_custom_loop, genesis_loop

  • This topic has 15 replies, 3 voices, and was last updated 4 years, 2 months ago by Brad Dalton.
Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • July 24, 2019 at 1:48 am #492527
    michaeloeser
    Member

    Hi guys,

    on a client site I suddenly get an error when opening a category archive:

    "Call to undefined function genesis_before_post()"

    I assume this happens since the last Genesis update but I´m not sure since it was just discovered today.

    I´m using a custom child theme which used to work without any issues since a long time. I assume I just need to change the function to some newer function, right?

    Any suggstions?

    UPDATE: in fact I was able to get rid of the main symptoms by commenting out the functions that are „undefined“. Seems like they are older functions that are not used in the latest Genesis version anymore.

    Is there a „old vs. new“ function reference available?

    July 24, 2019 at 1:50 am #492528
    Brad Dalton
    Participant

    Please paste the code which caused the problem.


    Tutorials for StudioPress Themes & WooCommerce.

    July 24, 2019 at 1:55 am #492529
    michaeloeser
    Member

    It´s some old function(s) obviously

    genesis_before_post()
    genesis_before_post_title()
    genesis_before_post_content()
    genesis_after_post_content()
    genesis_after_post()
    genesis_after_endwhile()
    genesis_loop_else()

    I assume there must be some newer function to replace them.

    July 24, 2019 at 1:59 am #492530
    Brad Dalton
    Participant

    Old hooks have been replaced by new ones.

    Try genesis_before_entry


    Tutorials for StudioPress Themes & WooCommerce.

    July 24, 2019 at 2:10 am #492531
    michaeloeser
    Member

    I get "Call to undefined function genesis_before_entry()"

    See: https://www.car-it.com/category/news

    Do I have to change any else setting?

    July 24, 2019 at 2:11 am #492532
    Brad Dalton
    Participant

    Please paste the entire code snippet, not just one line.


    Tutorials for StudioPress Themes & WooCommerce.

    July 24, 2019 at 2:36 am #492533
    michaeloeser
    Member

    Ok this is the whole code of the category.php file.
    Error see: https://www.car-it.com/category/news

    <?php
    /**
     * Category Template - generic
     */
    
    /**
     * Prevent direct access to this file.
     *
     * @since 1.0.0
     */
    if ( ! defined( 'WPINC' ) ) {
    	exit( 'Sorry, you are not allowed to access this file directly.' );
    }
    
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'dp_amtv_category_generic_loop_helper' );
    /**
     * Add custom loop helper for "Big Data" category.
     */
    function dp_amtv_category_generic_loop_helper() {
    
    	?>
    
    		<?php $i=1; if (have_posts()) : while (have_posts()) : the_post(); // the loop ?>
    
    			<?php genesis_before_entry(); /////genesis_before_post();  ?>
    			<div <?php post_class(); ?>>
    
    				<?php /////genesis_before_post_title(); ?>
    				<h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    				<?php /////genesis_after_post_title(); ?>
    
    				<?php /////genesis_before_post_content(); ?>
    				<div class="entry-content">
    				<?php
    					if(genesis_get_option('content_archive') == 'full') :
    						the_content(__('[Read more...]', 'genesis'));
    					else :
    					if(genesis_get_option('thumbnail'))
    					genesis_image(array('format' => 'html', 'size' => genesis_get_option('image_size'), 'attr' => array('class' => 'alignleft post-image')));
    					the_excerpt();
    					endif;
    				?>
    				</div><!-- end .entry-content -->
    				<?php /////genesis_after_post_content(); ?>
    
    	<?php if($i == 2 ) : ?>
    				<!-- Banner 1 -->
     <?php
     // Include the content ad format 1st position on archives
    	if ( !is_category ( array ('t-systems-subnet','plm','siemens-subnet') ) ) {
    	 include(CHILD_DIR.'/inc/category-ad.php');
    	 } ?>
     <?php elseif ($i == 4 ) : ?>
     <!-- Banner 2 -->
     <?php
     // Include the content ad format 2nd position on archives
     if ( !is_category ( array ('t-systems-subnet','plm') ) ) {
    	 include(CHILD_DIR.'/inc/category-ad2.php');
    	 } ?>
    
     <?php elseif ($i == 6 ) : ?>
    	<!-- Banner 3 -->
     <?php // Include the content ad format 3rd position on archives
    	if ( !is_category ( array ('t-systems-subnet','plm') ) ) {
    		 include(CHILD_DIR.'/inc/category-ad3.php');
    		 } ?>
    
     <?php /* elseif ($i == 8 ) : ?>
    	<!-- Banner 4 -->
    	<?php // Include the content ad format 4th position on archives
    	 if ( !is_category ( array ('t-systems-subnet','plm') ) ) {
    		 include(CHILD_DIR.'/inc/content-ad4.php');
    	 } */?>
    
     <?php endif; ?><!-- end if Abfrage für Banner -->
    
    			</div><!-- end .postclass -->
    			<?php /////genesis_after_post(); ?>
    
    		<?php $i++; endwhile; // end of one post ?>
    		<?php /////genesis_after_endwhile(); ?>
    
    		<?php else : // if no posts exist ?>
    		<?php /////genesis_loop_else(); ?>
    			<p><?php _e('Sorry, no posts matched your criteria.', 'genesis'); ?></p>
    		<?php endif; // end loop ?>
    
    	<?php
    
    }  // end function
    
    /**
     * Let Genesis take over again
     */
    genesis();
    July 24, 2019 at 2:43 am #492534
    Brad Dalton
    Participant

    You should be able to swap out the old hooks with the new ones.

    What theme are you using?


    Tutorials for StudioPress Themes & WooCommerce.

    July 25, 2019 at 11:51 pm #492583
    michaeloeser
    Member

    Even if I swap e.g. genesis_before_post() with genesis_before_entry(), I get "Call to undefined function genesis_before_entry()".

    See: https://www.car-it.com/category/news

    I don´t know exactly which old function to swap with which new one. That´s why I asked for a sort of table that says something like "this is the old function A and this is the new function A" etc.

    I´m using a custom child theme.

    July 25, 2019 at 11:58 pm #492584
    Brad Dalton
    Participant

    Where did you get the code from?

    Try do_action( 'genesis_before_entry' );


    Tutorials for StudioPress Themes & WooCommerce.

    July 31, 2019 at 4:58 am #492685
    Victor Font
    Moderator

    You're not calling genesis_before_entry correctly. genesis_before_entry is an action hook, it is not a function so the error you are receiving is correct.

    The correct way of calling genesis_before_entry is:

    do_action( 'genesis_before_entry' );

    Look through genesis/lib/structure/loops.php for the correct way to call the action hooks you're calling as functions.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    July 31, 2019 at 5:21 am #492686
    Brad Dalton
    Participant

    @michaeloeser Also, another way to create a custom loop is to use genesis_custom_loop


    Tutorials for StudioPress Themes & WooCommerce.

    August 1, 2019 at 1:45 am #492705
    michaeloeser
    Member

    Thank you guys for your help.

    My issue is I´m much more of a designer than a coding guy but I will see what I can do.

    August 1, 2019 at 2:03 am #492707
    michaeloeser
    Member

    Is there anyone who can assist with the custom loop. Doesn´t have to be for free.

    August 1, 2019 at 2:17 am #492708
    Brad Dalton
    Participant

    Please contact me here and let me know exactly what you need [email protected]


    Tutorials for StudioPress Themes & WooCommerce.

    August 2, 2019 at 5:26 am #492741
    Brad Dalton
    Participant

    Something like you see in this video


    Tutorials for StudioPress Themes & WooCommerce.

  • Author
    Posts
Viewing 16 posts - 1 through 16 (of 16 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

© 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