This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 11.62 hours from now. Thank you for your understanding.

This topic contains 6 replies, has 2 voices.

Last updated by Lizzy den Haan 2 months ago.

Assigned support staff: Andreas W..

Author Posts
August 4, 2019 at 2:50 pm #4336583

Lizzy den Haan

Hi,

I am trying to: Use Advanced Custom Fields in Toolset Views Lite with a filter, I want it to only display post who have my ACF date field (called 'datum_optreden') in the future. I set the filter as:

datum_optreden is a string greater than or equal to TODAY()

But it's not filtering. It's just displaying all the post types, also the ones in the past.

Link to a page where the issue can be seen: hidden link (password is BentleysNew)

I expected to see: a filtered view, where only dates in the future are shown.

Instead, I got: all of the post types in this category, not filtered by the date.

August 5, 2019 at 2:50 pm #4341451

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for contacting the WPML Support Forum.

Do I understand right, that this iss does only occur on translated pages? If not, it might not be related to WPML.

Anyhow, I found the following code on the ACF support documentation which usually should make sure, that date fields will onlz be visisble for current and upcoming events:

<?php

// find date time now
$date_now = date('Y-m-d H:i:s');


// query events
$posts = get_posts(array(
	'posts_per_page'	=> -1,
	'post_type'			=> 'event',
	'meta_query' 		=> array(
		'relation' 			=> 'AND',
		array(
	        'key'			=> 'start_date',
	        'compare'		=> '<=',
	        'value'			=> $date_now,
	        'type'			=> 'DATETIME'
	    ),
	    array(
	        'key'			=> 'end_date',
	        'compare'		=> '>=',
	        'value'			=> $date_now,
	        'type'			=> 'DATETIME'
	    )
    ),
	'order'				=> 'ASC',
	'orderby'			=> 'meta_value',
	'meta_key'			=> 'start_date',
	'meta_type'			=> 'DATE'
));

if( $posts ): ?>

	<h2>Events on right now</h2>
	<ul id="events">
		<?php foreach( $posts as $p ): ?>
			<li>
				<strong><?php echo $p->post_title; ?></strong>: <?php the_field('start_date', $p->ID); ?> -  <?php the_field('end_date', $p->ID); ?>
			</li>	
		<?php endforeach; ?>
	</ul>

<?php endif; ?>

Source: hidden link

Let me know if this solved the issue and also please make sure to test, if the issue appears on default language while WPML and add-ons are disabled.

To help you faster, I've enabled debug information for this support ticket. Please see this link for how to get this information from your site and give it to us:
http://wpml.org/faq/provide-debug-information-faster-support/

Kind regards
Andreas

August 6, 2019 at 9:15 am #4345653

Lizzy den Haan

Hi Adreas,

Thank you for your reply. To answer to your first comment: "Do I understand right, that this iss does only occur on translated pages? If not, it might not be related to WPML.". ->

I don't have WPML activated on this site, but I do have Toolset Types and Toolset Views Lite (which I can download through my WPML account). I've created a custom post type, but Toolset Custom Fields-functionality wouldn't load. As a workaround, I used ACF to assign custom fields. But Toolset Views Lite doesn't play nice with this solution, since the view I'm using to display the custom fields doesn't seem to filter using the date.

I want to find a way for Toolset Views to 'read' the date picker generated date of ACF right, so I can apply a filter. Another way to fix this is to find the problem of the custom fields of Toolset not wanting to load, since I've never had a problem filtering the dates generated by Toolset custom fields.

Another note: since I don't have WPML installed and the site isn't and won't be multilingual, I can't provide the debug info as requested.

Hope you can help soon! This issue is taking me so much time and I really hope we can solve it 🙂 Thanks in advance for your time and effort.

Cheers,
Lizzy

August 6, 2019 at 11:06 pm #4350739

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for your message.

I have to admit that I am not that familiar as deveoper using Toolset and Advanced Custom Fields in combination. As far I understood you used the Toolset Types integration for visualizing ACF but now you would like to use a custom ACF visualization, right?

More information here:
https://toolset.com/documentation/user-guides/convert-existing-custom-types-and-fields-to-types-control/

Did you try the mentioned code from my last message? This is a solution provided by ACF. I would further advise you to reach out to their support for a solution.

hidden link

Also please take note that our support policy does not offer any custom coding solutions.

https://wpml.org/purchase/support-policy/

An alterantive here would be to reach out for the Toolset Support or a experienced Toolset contractor in order to obtain a custom solution for your needs.

https://toolset.com/forums/forum/professional-support/

https://toolset.com/contractors/

I hope for your understanding.

Kind regards
Andreas

August 7, 2019 at 10:30 am #4353841

Lizzy den Haan

Hi Andreas,

Thank you for your reply. I am not that familiar as well. Usually, I just use Toolset, but since I couldn't get the Toolset custom fields working I was trying to find another way.

I hope this time you will understand what I did:
- I used Toolset types to create a custom post type > WORKS
- since Toolset custom fields didn't work (stuck on a loading screen), I used ACF to create custom fields for the type > WORKAROUND WORKS
- used Views Lite to display the post loop with the custom fields >WORKS
- Trying to filter out dates in the past the way I usually do, by using the Query Filter of Toolset views Lite. Usually, this works beautifully, but I can't make Toolset views read the ACF date picker field I used correctly because it won't filter out the past dates. > PROBLEM IS HERE

This last point is my only problem. We could dive into why the Toolset Custom Fields is not loading, that would also solve the problem. But I think it's easier if you could help with a solution to the filter. Or a workaround to give dates in the past a different class so I can hide them or something.

I've looked at all the links you sent and have already tried for multiple hours to implement different solutions, but I haven't found a fix. And what more: Everything works on the site, it's all done, all I want is to hide the dates in the past from the front end view I created with Toolset.

I can't contact Toolset support since I don't have a login there and am using a complimentary version of Toolset types & views lite through my WPML account.

I hope you understand and are willing to please help me solve this. The origin of the problem is that Toolset isn't functioning correctly. I've already removed and reinstalled the plugins, switched themes and disabled all other plugins but I can't get it to work. So now I would love for a way to hide dates in the past.

Thank you so much in advance, I really hope you can help me out here.

August 8, 2019 at 12:29 am #4358675

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for your message.

I could offer you to find out why you were not able to use the Toolset types Custom Fields.

The case that you were not able to create custom fields with Toolset was possibly caused by a third plugin. Could you test if the issue disappears, if you disable all plugins but WPML and Toolset and their add-ons?

If the issue disappears please start deactivating the plugins one by one and simutaniously check in another browser window if the issue appears again. This way we can indicate which plugin is causing the issue and take further steps.

Enable the wp-debug feature to see if there are any current PHP errors given.

Add the following to your wp-config.php file:

define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

The wp-config.php is located in your WordPress root directory. It’s the same file where the database configuration settings are. You will have to access it by FTP or SFTP in order to edit it.

If you open wp-config.php and that define statement is not there, you can add it right before this line:

/* That's all, stop editing! Happy blogging. */

You will be able to find a complete report inside of your wp-content folder. Look for a debug.log file and provide me the results.

More information about how to activate this feature you can find here:
https://wpml.org/documentation/support/debugging-wpml/

I have created a new test site and installed the free Toolset plugins. Please recreate the issue. If is appears also on this new WordPress install I will escalate directly to our developers.

One Click Login: hidden link

You also might use this new install for own testing in the meantime.

In case you do prefer not to use Toolset Types and keep using ACF so please let me consult our second tier support for a solution but in order to do this it would be helpful to obtain more information about:

1) Detailed steps to recreate the issue.
2) Code used to implement ACF.
3) Access to your site or a Duplicator page in order to setup a copy locally.

Kind regards
Andreas

August 14, 2019 at 12:01 pm #4394707

Lizzy den Haan

Hey Andreas,

Thank you for your reply. Before you offered to help in this way I was in need of a quicker solution and managed to find another workaround by writing some PHP, adding a shortcode to add a class to the posts where the ACF date is in the past and then using display: none; to hide them.

FYI: it's not a plugin nor the theme causing the problem, that was the first thing I tested (disabled everything but Toolset types & views lite). By the way, I have used the plugins before and have never come across this problem, so I don't really know what's different this time.

Thanks for the effort and help, all the best!

Cheers,
Lizzy