Home › Forums › Calendar Products › Events Calendar PRO › Category view
- This topic has 5 replies, 2 voices, and was last updated 8 years, 11 months ago by
Jennifer.
-
AuthorPosts
-
June 7, 2017 at 2:51 am #1294296
Isto
ParticipantHi,
I want more info to category page.
I great new fields in ACF. When I go to events/category/category-name/ it shows the calendar. But when I try to shows those ACF-fields it shows some event infos.
Example the code echo get_the_ID(); shows some id of event, no category.
Could you help me?
June 8, 2017 at 12:01 am #1295046Jennifer
KeymasterHi Isto,
Thanks for reaching out! I’d be happy to help you with this.
I’m a little bit confused on what you are looking to do here. Are you adding custom fields to events using ACF? If so, I would recommend using the Additional Fields feature that comes with Pro instead. These fields will show up on your events by default.
I’m also not sure where you are trying to show the fields…are you trying to add these in somewhere on the calendar that shows on your category page? get_the_id does just return the unique ID of the post, so that won’t show any information on the event like the custom fields or category.
If you can provide some clarification on this, I’ll be happy to help you figure it out!
Thanks,
Jennifer
June 8, 2017 at 1:14 am #1295067Isto
ParticipantThis reply is private.
June 9, 2017 at 3:41 am #1295672Jennifer
KeymasterHi Isto,
Thanks for sharing those screenshots.
The file for event category pages and other event pages is the-events-calendar/src/views/default-template.php. It’s the same template for each page, and the tribe_get_view function determines what content gets loaded for the page, which in this case is the month view. So the category and non category event pages use the same views; the difference in which events are displayed is in the query.
I think what’s happening here is that because get_the_ID returns the ID for the current item in the WordPress loop, and the category page is looping through events with that category, the last event is the current item in the loop, which is why you are getting that event ID on your page.
To clarify, it looks like you used ACF to add custom fields onto event categories, is that correct? Are you trying to use a post ID to pull in those custom fields onto the front end category pages? If this is the case, I think what you’ll need to do instead is use tribe_is_event_category to check if you are on a category page, and then display your custom category fields if you are.
I found this post in ACF’s documentation that might be helpful in getting the terms to display on the front end. This post has an example of adding content to the category page. In that post, Nico is using the tribe_events_before_html hook, which would add your custom fields above the rest of the page content but below the header. If you want your fields elsewhere, you can take a look around in the-events-calendar/src/functions folder to find a hook that fires in the spot that you want to place your content. If you’re not familiar with what hooks look like, you’re looking for: do_action( ). Alternatively, you could add the custom fields directly to your event view templates. Our themer’s guide has some great tips on modifying our templates.
Ok, I know that was a lot of info, so please don’t hesitate to ask if you have questions on anything!
Thanks,
Jennifer
June 13, 2017 at 1:49 am #1297079Isto
ParticipantHi,
thanks for your reply.
I resolved this using post meta tags “$id = get_post_meta( get_the_ID(), ‘acf_field’, true );”
Thanks!
June 13, 2017 at 2:15 am #1297089Jennifer
KeymasterHi Isto,
I’m glad to hear you figured this out! It sounds like a neat customization. Thanks for sharing your solution here!
Since this thread has been marked “resolved”, I’ll go ahead and close it out. Please feel free to open a new one if you have any more questions!
Thanks,
Jennifer
-
AuthorPosts
- The topic ‘Category view’ is closed to new replies.
