[Resolved] Add ACF to WPSP

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Add ACF to WPSP

Tagged: , , , ,

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #33426
    Zlatan
    Participant

    Hi,

    I am trying to show a badge on some of my posts in a wpsp list with the ID number 79. I have created a True/False ACF field called “multiple_images”.
    If the field is true I would like to hook the following code:
    <div class="badge"><span>Gallery</span></div>

    With PHP it would look something like this:

    <?php if ( get_field( 'multiple_images' ) ): ?>
    <div class="badge"><span>Gallery</span></div>
    <?php else: // field_name returned false ?>
    <?php endif; // end of if field_name logic ?>

    How exactly do I put it in the hook “wpsp_before_content”?

    I have tried this, but unfortunately it is not working:

    add_action( 'wpsp_after_content', function( $settings ) {
        if ( 79 === $settings['list_id'] ) 
    		
    <?php if ( get_field( 'multiple_images' ) ): ?>
    <div class="badge"><span>Gallery</span></div>
    <?php else: // field_name returned false ?>
    <?php endif; // end of if field_name logic ?>
    
    } );

    Thanks in advance,
    Zlatan

    #33428
    Zlatan
    Participant

    Actually I figured it out, I think.

    Used this code

    add_action( 'wpsp_before_header','wpsp_add_custom_meta' );
    function wpsp_add_custom_meta()
    {
        $meta = get_post_meta( get_the_ID(), 'multiple_images', true );
        if ( isset( $meta ) && '' !== $meta )
            echo '<div class="badge"><span>Gallery</span></div>';
    }

    and it works 🙂

    #33438
    elvin
    Moderator

    Hi Zlatan,

    Nice one! Glad you got it sorted.

    Here’s a list of hooks incase you need to move it somewhere else – https://wpshowposts.com/support/topic/bbpress-metadata-and-dates-in-wpshowposts/#post-28854

    Thanks for sharing it with us. 😀

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