Support

Account

Home Forums General Issues How to show post by Field Group name?

Solving

How to show post by Field Group name?

  • I want in this example:
    __________________________________________________________________

    1. Field Group name

    $field[‘label’] | $value | $field[‘append’]

    .
    .

    2. Field Group name

    $field[‘label’] | $value | $field[‘append’]

    .
    .

    3. Field Group name

    $field[‘label’] | $value | $field[‘append’]


    .
    .
    _________________________________________________________________
    Can you help me?

  • This is code that I use now, but I need to show meta tag by the Field Group name.
    Please, help me…

    <?php while ( have_posts() ) : the_post(); ?>
     
        	<h3><?php echo get_the_title(); ?> </h3>
     
    		
              <?php
     
    $fields = get_fields();
     
    if( $fields )
    {
        foreach( $fields as $field_name => $value )
    	{
    		// get_field_object( $field_name, $post_id, $options )
    		// - $value has already been loaded for us, no point to load it again in the get_field_object function
    		$field = get_field_object($field_name, false, array('load_value' => false));
    echo "<table  width='98%'>
      <col width='100'>
      
      <col width='50'>
      <col width='100'>
      
         
       
    ";
    
        if($value != "")
        {
      echo "<tr>";
      echo "<td><b>" . $field['label'] . "</b></td>";
      
      echo "<td align='center'>" . $value . "</td>";
      echo "<td align='right'>" . $field['append'] . "</td>";
          echo "</tr>";
      echo "<hr>";
        }
    echo "</table>";
    
    	}
       
    }
    
     
    ?>
                
    		<?php endwhile; // end of the loop. ?>
  • Hi @Valbon

    Sorry, I don’t understand what you mean by:
    “show meta tag by the Field Group name”

    Can you please be more descriptive and specific?

    Thanks
    E

  • Hi @elliot

    In the up code, all fields (meta tag) are shown, but I want to show fields after “Field Group Name” that have.

    Sorry for my bad writting.

  • Hi @Valbon

    I think you are asking how to load a field group? Is that correct?
    At the moment, there is no API functions to load the field group and it’s label, etc.

    You will have to hard code this information into your theme.

    Thanks
    E

  • <?php get_header(); ?>
    
        <div id="content" class="list-post">
        
        
        <h3><?php echo get_the_title(); ?> </h3>
        
        
       
        	
    <?php while ( have_posts() ) : the_post(); ?>
     
        	
          
    		
    
    			
                
                
      <?php
      
              $acfs = apply_filters('acf/get_field_groups', false);
     foreach( $acfs as $acf )
        		{
    				// load options
    				$acf['options'] = apply_filters('acf/field_group/get_options', array(), $acf['id']);
    
    echo '<span>' . $acf['title'] . '</span>';
      
        
        $fields = get_posts($args);
      
      
        
        
    
    $fields = get_fields($args);
    
        foreach( $fields as $field_name => $value )
    	{?>
            
           <?php   
    		//get_field_object( $field_name, $post_id, $options )
    		// - $value has already been loaded for us, no point to load it again in the get_field_object function
    		$field = get_field_object($field_name, false, array('load_value' => false));
            
        
            
           echo "<b>" . $field['title'] . "</b>";
    echo "<table  width='98%'>
      <col width='100'>
      <col width='50'>
      <col width='100'>
           ";
           // shtese
     //echo "<b>" . $acf['title'] . "</b>";
     //shtese
        if($value != "")
        {
      echo "<tr>";
       
      echo "<td><b>" . $field['label'] . "</b></td>";
      
      echo "<td align='center'>" . $value . "</td>";
      echo "<td align='right'>" . $field['append'] . "</td>";
          echo "</tr>";
      echo "<hr>";
        }
    echo "</table>"; 
    	}} ?>
     
               		<?php endwhile;  ?>
        	
     
     
     <p><?php the_content(); ?></p>
          <?php get_the_time( $d, $post ); ?> 
          <p style="float:right;"> Publikuar në ora <b><?php echo get_the_time('G:i', $post->ID); ?></b> më <b><?php echo get_the_date('j.m.Y'); ?></b></p>
         
        </br>
        
        
                
    	</div>
    	<!-- /#content -->
    
    <?php get_sidebar(); ?>
    	
    <?php get_footer(); ?>

    Can you see code, what it’s displays?

    Now, I want to display field by category. But In one category(title=field group name) are displays all fields.

    Please help me, this is for my project in university.

  • Hi @Valbon

    Sorry, I don’t understand your question.
    It seems you have a good understanding of the plugin, but what you are asking doesn’t make much sense.

    Please be very specific and refrain from dumping huge amounts of code.

    Thanks
    E

  • In the WP to Post

    null

    My field group

    I what code to shown ~this form:

    Thank you.

  • Hi @Valbon

    To find field settings such as ‘append’, please use the get_field_object function and also the get_field_objects (to get many fields).

    Fore each ‘field’, you can render it like so:

    
    <tr>
    	<td><?php echo $field['label']; ?></td>
    	<td><?php echo $field['value']; ?></td>
    	<td><?php echo $field['append']; ?></td>
    </tr>
    

    Reference: http://www.advancedcustomfields.com/resources/functions/get_field_object/

    Hope that helps.

    Thanks
    E

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘How to show post by Field Group name?’ is closed to new replies.