
Tagged: acf fields
-
AuthorPosts
-
March 28, 2025 at 1:08 pm #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
March 31, 2025 at 7:28 am #1480506Hey Elena,
Thank you for the inquiry.
You can add 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,
IsmaelMarch 31, 2025 at 9:29 am #1480511Hi 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 1 day, 21 hours ago by
elenapoliti.
April 1, 2025 at 5:23 am #1480553Hi,
Thank you for the update.
We may need to inspect the page and access the dashboard to properly check the modification. Please provide the site URL and login details in the private field.
Best regards,
IsmaelApril 1, 2025 at 1:09 pm #1480579Hi the site is under development on a local folder. I just uploaded a copy of it in a subdirectory. Below the url and the access.
Check the home page: the span.post-meta-infos doesn’t contain the custom fields as set in my functions.php
Thanks
April 2, 2025 at 5:31 am #1480610 -
This reply was modified 1 day, 21 hours ago by
-
AuthorPosts
- You must be logged in to reply to this topic.