0

I'm pretty new to WordPress coding. I currently use Themler for my WordPress theme which allows you to put a CMS Code container right into the page and display any WordPress code.

I am using the "Custom Post Type UI" plugin, and the "Advanced Custom Fields" plugin. I have created a custom post type "events". I included three native WordPress fields for the custom post type, and added three more custom fields via the ACF plugin. The fields are as follows:

Native WordPress Fields:

  • Title
  • Editor
  • Featured Image

Custom fields from ACF plugin:

  • event_date (date picker field)
  • event_theme (text field)
  • event_registration (file field)
  • event_additional_info (Wysiwyg Editor field)

What I'm struggling with is how to display these fields on my homepage via the CMS Code container in Themler. The code container accepts any WordPress code, so it doesn't have to be anything special to comply. I'm just not knowledgeable enough on WordPress code to come up with it. I plan to display three events on my homepage and include the fields above in that display. I've tried a bunch of different pieces of code I've found, but some only show the native fields, and some only show the custom fields. I think its just my lack of understanding on how to make it all work. Would anyone be able to throw me the code to display this? I'm a quick learner and great with HTML/CSS, so I should be able to take it and run from there.

Thanks in advance!

1
  • You'll have to check the documentation for each of the respective plugins to see how they recommend you display the information - these are two third party plugins and they do things different than WordPress itself does (sometimes/in some cases)... Also, what is a CMS Code Container? Commented Mar 5, 2021 at 17:13

1 Answer 1

0

I'm not using your theme. But if you want to call ACF field to frontend. just using below code.

<?php echo get_field('slug_acf_field'); ?>
3
  • Thanks for the code, I gave that a try on the homepage, but its not returning anything? Do I need some sort of setup code or preceding code before I call that? I apologize for my ignorance, I'm super new at this so I have no idea where to start. I have not associated the custom post type with my homepage at all, I've only created a post under that category and want to display the fields on the homepage of my site. I'd like to be able to display three or so posts on the homepage too if possible using those fields. Commented Mar 4, 2021 at 23:59
  • As far as I remember get_field reads values from postmeta, so if you're on the homepage which doesn't have a specific post then you don't have anything to read fields from, no. You can pass a post ID into get_field I think if you always want to read these from a specific post even if it's not in context.
    – Rup
    Commented Mar 5, 2021 at 10:14
  • Thank you, that did the trick! I decided that I'll probably add a Post Object field using ACF to the homepage, and then add the posts I'd like to use through that field. I appreciate the help! Commented Mar 5, 2021 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.