[Resolved] Display post from custom post type

Home Forums Support [Resolved] Display post from custom post type

Home Forums Support Display post from custom post type

  • This topic has 3 replies, 2 voices, and was last updated 3 weeks ago by Elvin.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2068147
    Rick

    I’m using this code in a Hook Element to display custom fields from the WordPress post type.

    <?php
    $website_custom_field = get_post_meta( get_the_ID(), 'website', true );
    $email_custom_field = get_post_meta( get_the_ID(), 'email', true );
    
    echo "<p style='padding-top:20px;'><strong>Website:</strong> " .$website_custom_field. "<br>";
    echo "<strong>Email:</strong> " .$email_custom_field. "</p>";
    ?>

    How would I do the same for the custom post type ‘asd-providers’. I’m using Custom Post Type UI and Advanced Custom Fields in this scheme.

    Thanks!
    -Rick

    #2068208
    Elvin
    Staff
    Customer Support

    Hi Rick,

    If you want to use the same Hook element, you can edit its display rule location to add more custom post type.

    Example: https://share.getcloudapp.com/kpu4ywDW

    The code doesn’t seem to need any change unless your CPT isn’t set to have the specified custom fields. But if they are, then it should be fine as get_post_meta( get_the_ID() works in loops regardless of post type.

    A wise man once said:
    "Have you cleared your cache?"

    #2068220
    Rick

    Yep, that did it… so easy. Thanks!
    -Rick

    #2068238
    Elvin
    Staff
    Customer Support

    No problem. Glad you got it sorted. 😀

    A wise man once said:
    "Have you cleared your cache?"

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