Use Custom Post Class in a custom loop

Community Forums Forums General Discussion Use Custom Post Class in a custom loop

This topic is: resolved

This topic contains 1 reply, has 1 voice, and was last updated by  simbasounds 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #107273

    simbasounds
    Member
    Post count: 20

    How would I access the Custom Post Class (as optionally defined in Layout Settings for each post) in php?
    (and also, if possible, a check to see if a Custom Post Class has been defined?)

    I have a custom post type “rows”, and a custom page template with a custom loop.
    I would like to apply the custom class to my <section> tag.

    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'rows_loop' );
    function rows_loop() {
    	$args = array('post_type' => 'row',);
    	$loop = new WP_Query( $args );
    	if( $loop->have_posts() ) {
    		// loop through posts
    		while( $loop->have_posts() ): $loop->the_post();
    			<section>
    				// loopy stuff here
    			</section>
    		endwhile;
    	}
    }

    I’d be happy to be redirected to any relevant documentation. Many thanks.

    http://themeselector.com/slimsonic/
    #107312

    simbasounds
    Member
    Post count: 20

    I found it in genesis/lib/structure/post.php

    $post_class = genesis_get_custom_field( '_genesis_custom_post_class' );

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.