Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6761925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:15:02+00:00 2026-05-26T14:15:02+00:00

I have setup a custom post type in WordPress. It is a section where

  • 0

I have setup a custom post type in WordPress. It is a section where the client can upload documents in PDF format. The documents are divided into two categories – ‘Downloadable Forms’ and ‘Menu’ ; the Custom Field name for the category is ‘document_category’

I am trying to run a query and only display the ‘Downloadable Forms’ on a page. Here is the code I normally use — I’m hoping someone can help me add what I need to make it work?

<?php       
$args = array('post_type' => 'prep_forms', 'posts_per_page' => -1);
// The Query
$the_query = new WP_Query( $args );
// The Loop
$i = 0;
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<li><a href="<?php echo get_field('document_pdf_file'); ?>"><?php the_title(); ?></a></li>
<?php
$i++;
endwhile;
// Reset Post Data
wp_reset_postdata();
?>

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:15:02+00:00Added an answer on May 26, 2026 at 2:15 pm
    <?php       
    $args = array('post_type' => 'prep_forms', 'posts_per_page' => -1);
    // The Query
    $the_query = new WP_Query( $args );
    // The Loop
    $i = 0;
    while ( $the_query->have_posts() ) : 
        $the_query->the_post();
        // Get all Advanced custom fields
        $my_custom_fields = get_fields(get_the_ID());
        // Does document_category field exists and is it equal with 'Downloadable Forms'?
        if(isset($my_custom_fields['document_category']) && $my_custom_fields['document_category'] == 'Downloadable Forms'):
    ?>
    <li><a href="<?php echo get_field('document_pdf_file'); ?>"><?php the_title(); ?></a></li>
    <?php
        endif;
    $i++;
    endwhile;
    // Reset Post Data
    wp_reset_postdata();
    ?>
    

    I’ve used the get_fields($post_id = false) function of the Advanced Custom Fields plugin that returns an array of all the posts’ custom fields and then filtered it to match your needs.

    Hope i’ve helped

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have setup a custom Post Type in WordPress and have a question. How
I have a WordPress custom post-type setup. I've created single-[customposttype].php However instead of displaying
I have a custom taxonomy setup called albums, and a new album can be
At the moment I have setup a custom ok cancel dialog with a drop
I'm trying to setup custom validation for a checkbox. I have 7 checkboxes each
Is it possible to have nested set capabilities in this somewhat custom setup? Consider
I have visual studio setup project with a custom RadioButtons dialog. How do I
I have created a custom dialog for Visual Studio Setup Project using the steps
Not sure how to word this. I've set up a custom post type in
I am doing some custom audio post-processing using audio units. I have two files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.