WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Advanced Custom Fields] Getting started with Advanced Custom Fields. (1 post)

  1. Developher
    Member
    Posted 3 months ago #

    I am a compete beginner with Advanced Custom Fields. I would like to get your help in understanding acf well, most probably a simple question.

    I have a blog I use acf to categorize the posts. I use radio buttons to chose the category and the wordpress default WYSIWYG editor for the content. For example, the post categories are: sub categories are indexed:

    Post type: article

    field name : post_categories

    Type : Radio Button

    internet
    --HTML
    --CSS
    programming
    --Python
    --PHP
    --Java
    --ObjectiveC
    electronics
    --Analogue
    --Digital
    --MicroControllers
    --Arduino
    design
    --Photoshop
    --Illustrator
    --AfterEffects
    --Cinema4D

    FIELD NAME: POST EXTRAS

    Type: Text SubHeading Type: Image Post Image

    Please help me get to know how to,
    1. Get Latest 3 articles from each Category.
    2. In the latest 3 categories, how to include a text that looks like, 'posted in (subcategory) under (category)'.
    3. How to include the subheading ?? can i just use 'the_field('SubHeading');' ???
    can use any text case. much thanks from the bottom of my heart for the help.

    my code is as follows

    <?php
    // args
    $args = array(
        'numberposts' => -1,
        'post_type' => 'article',
        'meta_query' => array(
        'relation' => 'OR',
    array(
        'key' => 'internet',
        'value' => 'CSS',
        'compare' => 'LIKE'
    ),
    array(
       'key' => 'programming',
       'value' => 'ObjectiveC',
       'compare' => 'LIKE'
    )
    )
    );
    // get results
    $the_query = new WP_Query( $args );
    // The Loop
    ?>
    <?php if( $the_query->have_posts() ): ?>
    <ul>
    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
      <li>
         <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
      </li>
    <?php endwhile; ?>
    </ul>
    <?php endif; ?>
    <?php wp_reset_query();  // Restore global post data stomped by the_post(). ?>

Reply

You must log in to post.

About this Topic