Skip Navigation

[Closed] Conditionals and taxonomy custom fields

This support ticket is created 3 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Christian Cox 3 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1940577

Hello,

Assuming I call this view by in a php taxonomy template called "section".

taxonomy-section.php : 89

<?php print( do_shortcode('[wpv-post-body view_template="presentation-contenu-section"]') ); ?>
 

This taxonomy have a custom field which is a RTE field called "wpcf-s-content".

I have a shortcode "has_content" simply returning true or false if $content exists.

function func_has_content($atts, $content='') {
    // provide defaults
    $atts = shortcode_atts(
        array(
        ),
        $atts
	);
	$return = false;
	$content = wpv_do_shortcode($content);
	if ( strip_tags($content) != '' ) $return = true;
  	return $return;
}
add_shortcode( 'has_content', 'func_has_content' );
 

I'm trying this :

[wpv-taxonomy-field name="wpcf-s-content"]
[types termmeta="s-content" output="raw"][/types]
 

both returning the content

[has_content][wpv-taxonomy-field name="wpcf-s-content"][/has_content]
 

returning 1

[wpv-conditional if="( '[has_content][wpv-taxonomy-field name='wpcf-s-content' term_id='[wpv-taxonomy-archive info='id']'][/has_content]' eq '1' )" debug="true"]A[/wpv-conditional]
 

returning nothing

[wpv-conditional if="( '[wpv-taxonomy-field name="wpcf-s-content"]' eq '1' )" debug="true"]B[/wpv-conditional]
 

returning nothing

[wpv-conditional if="( '[types termmeta="s-content" output="raw"][/types]' eq '1' )"debug="true"]C[/wpv-conditional]
 

returning nothing

If I use multiple time [has_content] + inside a conditional, then it fails to close the shortcode :

".... [/has_content] "

Thanks a lot,
Best regards,
Wilhem

#1940719

Ok, i had to move on, so I managed it by php.
But I still think there is an issue with wpv-conditional.

In RTE wpcf-s-content I could have some <span style="color: #...."></span> inside.

#1941459

If you'd like to set this up in a test environment and give me login and FTP access, I'll be glad to take a closer look. Private fields are active here. If you don't have access to a public test environment let me know and I can set up a sandbox site for you to use.

#1948725

Hello Christian,

I'll be happy to give you an FTP access ; but as I said I choose to make it work via PHP.
The issue should be located here :

.... <span style="color: #....">< ....
Inside the RTE content, the double quote failed.

Best regards,
Wilhem

#1951767

I understand, and I'd like to have FTP access so I can activate PHP error logging to debug the code line-by-line if necessary, and I'd like to have wp-admin access to be able to easily test different values in the WYSIWYG field.

The topic ‘[Closed] Conditionals and taxonomy custom fields’ is closed to new replies.