[Resolved] Hook for Single Custom Post Type Page

Home Forums Support [Resolved] Hook for Single Custom Post Type Page

Home Forums Support Hook for Single Custom Post Type Page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #545938
    Ben

    Hi Guys,

    I have a site i’m building which is based around a program of Events for a Festival.

    I’m using Custom Post Type UI to create the custom Events post type, and Advanced Custom Fields to create specific fields (date, time, venue etc) for the events.

    For the events archive page I am using WP Show Posts to show the list of events and am using a function hook the custom fields in to those listings (see https://3bm.net.au/events-program/).

    I am now trying to do the same thing for the single post page (which i’m not using WPSP for) but am struggling with the code, see below. Any idea what i am doing wrong?

    add_action( 'after_entry_header', 'bm_add_after_entry_header' );
    
    function bm_add_after_entry_header() {
        
        $date = get_post_meta( get_the_ID(), 'event_date', true );
        $time = get_post_meta( get_the_ID(), 'event_time', true );
        
        
        if ( isset( $date ) && '' !== $date ) {
            
            if ( isset( $time ) && '' !== $time ) {
            	echo '<p>'.$date.' / '.$time.'</p>';
            } else {
    	        echo '<p>'.$date.'</p>';
    	      }    
        }
        
    
    }

    Thank you,
    Ben

    #546431
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Instead of: after_entry_header

    Try: generate_after_entry_header

    #546779
    Ben

    Yep that did it – thanks Tom, brilliant.

    #546817
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.