Support

Account

Home Forums General Issues getting sub-fields and limit number of posts

Solved

getting sub-fields and limit number of posts

  • I am a compete beginner with acf. I have tried the post tutorials on the site and its working well for me. okay 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

    Here I know how to get articles of different categories using the tutorials provided. Please help me 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

    <?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(). ?>
Viewing 1 post (of 1 total)

The topic ‘getting sub-fields and limit number of posts’ is closed to new replies.