Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1480360

    I have created a CPT with ACF and relative custom fields. Then I show the posts in specific pages with the avia element Blog Post. When choosing the style “Simple List”, I would like to show a couple of psot custom fields instead of Author and Date.

    I am not sure which filter I should use in functions.php to do it, or if I should modify a copy of some enfold file in my child theme. I tried to modify the loop-index.php but no changes are reflected in the front-end

    Thanks

    #1480506

    Hey Elena,

    Thank you for the inquiry.

    You can this in the includes > loop-index.php file around line 471:

    echo '<span class="post-meta-infos">';
    

    Create a copy in your child theme, then do the modifications. You can also use the avf_post_metadata_array filter.

    Example:

    add_filter('avf_post_metadata_array', function($meta, $context) {
        global $post;
    
        if($context == 'loop-index') {
            $updated_date = get_the_modified_date('F j, Y', $post->ID); 
            $meta['updated_date'] = '<span class="blog-updated-date minor-meta">Updated on: ' . $updated_date . '</span>';
        }
    
        return $meta;
    }, 10, 2);

    Best regards,
    Ismael

    #1480511

    Hi Ismael I tried to modify the loop-index.php, by creating a copy in my child theme.

    I added these few lines

    		if( $blog_style !== 'bloglist-compact' )
    				{
    					echo '<span class="post-meta-infos">';
    
    						$meta_info = array();
    
    						/**
    						 * @since 4.8.8
    						 * @param string $hide_meta_only
    						 * @param string $context
    						 * @return string
    						 */
    						$meta_separator = apply_filters( 'avf_post_metadata_seperator', '<span class="text-sep">/</span>', 'loop-index' );
    
    						/***MODIFICATION  */
    						if(get_post_type() == 'project') {
    							
    							$meta_acf = '<span class="meta_acf">';
    							$custom_field_1 = get_field('project_start_date');
    							$custom_field_2 = get_field('tethys_role');
    
    							if (!empty($custom_field_1)) {
    								$meta_acf .= '<span class="meta-info custom-meta"><strong>Field 1:</strong> ' . esc_html($custom_field_1) . '</span>';
    							}
    
    							if (!empty($custom_field_2)) {
    								$meta_acf .= '<span class="meta-info custom-meta"><strong>Field 2:</strong> ' . esc_html($custom_field_2) . '</span>';
    							}
    							$meta_acf .= '</span>';
    
    							$meta_info['acf'] = $meta_acf;
    
    						}
    						
    						/**END MODIFICATION */
    

    I am working with a CPT named ‘project’. From the theme options I deselected the visualization of author and post date, since I am not interested in those meta info. Then I added the lines above in the loop-index.php just after the line
    echo '<span class="post-meta-infos">';
    but I don’t see anything.

    Thanks for helping

    • This reply was modified 8 hours, 48 minutes ago by elenapoliti.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.