-
AuthorPosts
-
November 7, 2020 at 10:22 am #1259024
Hello, I have added a field to the blog posts to be seen in the posts. Where can I find the masonry php file to add that field
November 9, 2020 at 4:35 am #1259168Hey jeiceta,
I’m not sure I understand your question, could you try to explain a bit further, or post a screenshot highlighting your intentions please?
Best regards,
RikardNovember 10, 2020 at 12:31 am #1259437Hello, I have added a field to the blog posts. On the blog page I put the content element that you see in image1. And on the web it looks like in the image2. I want it to look like in image 3 where I have added the year field (it could be another). In which file (php or other) can I add that field?
Imagen1
Imagen2
Imagen3
November 12, 2020 at 3:45 am #1260036Hi,
Thank you for the inquiry.
We have to modify the enfold\config-templatebuilder\avia-shortcodes\postslider\postslider.php file and add the year above the featured image markup, which is around line 772 of the said file.
$output .= $thumbnail ? "<a href='{$link}' data-rel='slide-" . avia_post_slider::$slide . "' class='slide-image' title='{$image_link_title}'>{$thumbnail}</a>" : '';
Did you add the year as a custom field? If so, then we could use the get_post_meta function to get the value of the custom field and render it in the page.
// https://developer.wordpress.org/reference/functions/get_post_meta/
Best regards,
IsmaelNovember 12, 2020 at 4:22 am #1260041Hello, thanks for your answer. I put this code “echo get_field (“Date”);” How would I put it where you indicate?
November 15, 2020 at 5:38 am #1260557Hi,
Thank you for the info.
Above the code that we mentioned above, try to add this line.
$year = get_field ("Date"); $output .= "<span class='slide-year-meta'>".$year."</span>";
This should render the Date above the featured image. We could then use the .slider-year-meta selector to adjust the style of the year info.
Best regards,
IsmaelNovember 16, 2020 at 1:25 am #1260607Hello, thank you agani. Now the field appears. But the date (the field) of the first post is repeated in the rest. That is, it only puts a single date, that of the first post published in all posts. It does not take the one from each field.
November 16, 2020 at 1:45 am #1260609Is a text field
November 19, 2020 at 6:36 am #1261464Hi,
Thank you for the update.
We may have to add the post ID to the get_field function so that it returns the actual year from each post. Please look for the line where we defined the $year variable and replace it with the following code.
$year = get_field ("Date", $entry->ID);
// https://www.advancedcustomfields.com/resources/get_field/
Best regards,
IsmaelNovember 19, 2020 at 3:19 pm #1261573Hello. Perfect. Works. It’s what I needed. Many thanks
November 19, 2020 at 3:24 pm #1261574One more question. If I wanted to put it in the masonry widget, where would I have to put it?
November 19, 2020 at 3:24 pm #1261575Hi,
Glad Ismael could help! :)
For your information, you can take a look at Enfold documentation here – https://kriesi.at/documentation/enfold/
If you have any other questions or issues, feel free to start a new thread under Enfold sub forum and we will gladly try to help you :)
Enjoy the rest of your day!
Best regards,
Yigit -
AuthorPosts
- The topic ‘How to put a field in blog posts in masonry’ is closed to new replies.