0
votes

I am using a WordPress plugin called Types and for the life of me, I cannot figure out how to extract the content of these Custom Types in WordPress?

I've done this before for regular Posts but I am not sure what I am doing wrong for Custom Post Types?

Here's the last block of code I've tried from the WP Codex:

       <?php
          $query = new WP_Query( 'name=footer-address-details' );
            if ( $query->have_posts() ) {
            while ( $query->have_posts() ) {
            $query->the_post();
            echo get_the_content();
          }
          } else {
          // no posts found
          }
          /* Restore original Post Data */
          wp_reset_postdata();
        ?>

I need to extract only this piece of data by slug-name (footer-address-details) from the DB.

Is there something I am missing here?

Thank you!

1

1 Answers

1
votes

I think you need to specify your post type in the query, otherwise it will just search the regular posts

$args = array(
  'post_type' => 'custom_post_type',
  'name' => 'footer-address-details'
);

$query = new WP_Query( $args );