Re: https://toolset.com/forums/topic/business-hours/
Hi Waqar! Okay, this is what I've got so far. I'm trying to add this to a widget in the sidebar, but no luck.
Hello, can you explain how you are trying to add this to a widget in the sidebar? Are you using custom PHP code, or are you placing Types field shortcodes inside a widget area? Can you copy + paste an example of the PHP or shortcodes you are using, and some screenshots showing how you have placed them in the widget?
In general, the format for displaying a custom field using the Types field shortcode system is like this:
[types field="field-slug"][/types]
Replace field-slug with the slug of the custom field you want to display. Other attributes available for this shortcode are explained in the documentation link below.
In general, the format for displaying a custom field using the Types PHP API is like this:
<?php echo(types_render_field( 'field-slug' )); ?>
Replace field-slug with the slug of the custom field you want to display. You can add other attributes as arguments in an array like this:
<?php echo(types_render_field( 'field-slug', array( 'arg1' => 'val1', 'arg2' => 'val2' ) )); ?>
Documentation for the shortcode approach and the PHP approach:
https://toolset.com/documentation/customizing-sites-using-php/functions/
Hey, Christian, thank you. Do you think we can get Waqar back on this? He knows what's going on from the beginning which includes another post type and a completely different setup.
Hello, yes of course, I can transfer this ticket to Waqar. Please stand by and he will follow up with you when he is available.
Hi,
Thank you for waiting and for the screenshots.
The opening and closing hours custom fields for the weekdays seem to be added correctly.
Can you please share some details about how exactly you tried to show these hours in the sidebar widget? Please also share the link to an example page, where this widget can be seen.
Note: I already have the admin access details for the website.
regards,
Waqar
Hi, Waqar. The method that Mineeh gave me uses this in the sidebar;
<div class="hours-box resthours r-type-2">
[wpv-view name="restaurants-hours-block"]
</div>
</div>'
Now I'm trying to use the next custom fields:
'<div class="hours-box alloperatinghours r-type-2">
[wpv-view name="hours-block"]
</div>
</div>'
and I get this: (image attached). you can see "No items found" in the sidebar.
The post field group is all operating hours.
Link is /shop/maude-main-gift-shop/.
Thank you for sharing these details.
Now, that you're using regular custom fields for opening/closing hours, without any repeatable field group, you don't need a view to show them.
You can use the field shortcodes directly in the content templates and in the sidebar widgets:
https://toolset.com/documentation/customizing-sites-using-php/functions/
For example:
<strong>Mondays:</strong>
[types field='opening-hours-mondays'][/types] - [types field='closing-hours-mondays'][/types]
<strong>Tuesdays:</strong>
[types field='opening-hours-tuesdays'][/types] - [types field='closing-hours-tuesdays'][/types]
<strong>Wednesdays:</strong>
[types field='opening-hours-wednesdays'][/types] - [types field='closing-hours-wednesdays'][/types]
<strong>Thursdays:</strong>
[types field='opening-hours-thursdays'][/types] - [types field='closing-hours-thursdays'][/types]
<strong>Fridays:</strong>
[types field='opening-hours-fridays'][/types] - [types field='closing-hours-fridays'][/types]
<strong>Saturdays:</strong>
[types field='opening-hours-saturdays'][/types] - [types field='closing-hours-saturdays'][/types]
<strong>Sundays:</strong>
[types field='opening-hours-sundays'][/types] - [types field='closing-hours-sundays'][/types]
You can see this in the sidebar widget at /shop/maude-main-gift-shop/
Thank you so much, Waqar! My hero!
Thank you so much, Waqar! My hero!
My issue is resolved now. Thank you!
Can I re-open this thread?