Skip Navigation

[Resolved] 404 Error on your TOOLSET website forum

This support ticket is created 2 years, 8 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 8 replies, has 2 voices.

Last updated by nedG 2 years, 8 months ago.

Assisted by: Waqar.

Author
Posts
#2315575

Normally I google search for issues with TOOLSET and i can find my answers using the Google Results thatprovide links to your support forum.

Now all of those links are providing a 404 error on your site.

For example, I Googled "toolset conditional only display posts with featured image"

The top 3 results were..

https://toolset.com/forums/topic/conditional-display-of-featured-image/
https://toolset.com/forums/topic/retrieve-only-posts-with-a-featured-image/
https://toolset.com/forums/topic/conditional-output-with-feature-image/

All of these links get a 404 Error.

When will your support form be fixed?

#2315927

Hi,

Thank you for contacting us and I'd be happy to assist.

We're in the process of removing the old support forums threads, which include information that is no longer applicable or outdated.
( The support forum threads which are two years older are archived, and only supporters and users who started them will have access to them. Forum threads older than 5 years have been removed )

To conditionally show some content, only if the featured image is set, you can use the "wpv-post-featured-image" shortcode ( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-featured-image ) in the conditional statement like this:
( ref: https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/ )


[wpv-conditional if="( '[wpv-post-featured-image output="url"]' ne '' )"]
// show some content only if featured image is set				
[/wpv-conditional]

We'll recommend using our forum search ( https://toolset.com/forums/forum/professional-support/ ) instead of Google to search for the information that you're looking for. In case the information that you're looking for is not available, you can start a new ticket and we'll be happy to assist you accordingly.

regards,
Waqar

#2316545

Thanks Waqar for the update.

That's a bummer... because I have plenty of sites that still use the old Views/Content Templates instead of Blocks and a lot of the old support forum posts were quite useful.

For example, in my current issue... I am creating a slider in Views. In the slider i created a bootstrap grid of 6 columns... so the HTML looks like this in Views...

<!-- wpv-loop-start -->
	<wpv-loop wrap="6" pad="true">
		[wpv-item index=1]
		<div class="row ">
			 <div class="col-sm-2">[wpv-post-body view_template="manufacturers-slider-slide"]</div>
		[wpv-item index=other]
			 <div class="col-sm-2">[wpv-post-body view_template="manufacturers-slider-slide"]</div>
		[wpv-item index=6]
			 <div class="col-sm-2">[wpv-post-body view_template="manufacturers-slider-slide"]</div>
		</div>
		[wpv-item index=pad]
			<div class="col-sm-2"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-2"></div>
		</div>
	</wpv-loop>
	<!-- wpv-loop-end -->

I only want to display posts that have a featured image. So I need a filter to do that.

I can't put a Conditional statement in the html code lines above or it will cause the bootstrap Grip to start missing columns.

#2316967

Thank you for sharing these details.

We're currently making some adjustments to the access to the old support forum threads and once completed, the details will be announced through our blog.

To filter out the posts without the featured images, at the view's query level, you can use the "wpv_filter_query" filter:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

For example:


add_filter( 'wpv_filter_query', 'wpv_filter_query_func', 1000 , 3 );
function wpv_filter_query_func( $query_args, $view_settings ) {
	// process if specific view
	if ( ( isset($view_settings['view_id']) && $view_settings['view_id'] == 12345) ) {
		$query_args['meta_query'][] = array(array('key' => '_thumbnail_id'));
	}
	return $query_args;
}

Note: You'll replace '12345' with your actual view's ID.

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

#2318609

Thanks Waqar,

That's fine but how can it be adapted for a taxonomy View and also a Custom Image?

I have a taxonomy slider as well (for Manufacturers) and it uses a custom filed image/logo called wpcf-logo-image

#2319739

Thanks for writing back.

In the case of a taxonomy view, you can use a custom function attached to the "wpv_filter_taxonomy_post_query" filter:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_post_query

For example, if you'd like to filter out terms from your taxonomy view with ID "12345", which don't have an image saved in the term custom field with slug "book-category-image", the code will look like this:


add_filter( 'wpv_filter_taxonomy_post_query', 'check_image_field_items', 20, 4 );
function check_image_field_items( $items, $tax_query_settings, $view_settings, $view_id ) {

	if( $view_id == 12345 ) {
		$term_field_slug = 'book-category-image';
		$new_items = array();
		for ($i=0; $i < sizeof($items) ; $i++) {
			$field_image = types_render_termmeta( $term_field_slug, array('term_id' => $items[$i]->term_id, 'output' => 'raw') );
			if (!empty($field_image)) {
				$new_items[] = $items[$i];
			}
		}
	}

	return $new_items;
}

#2319753

Hi Waqar,
I really appreciate your help.

I looked t the documentation and I added the following code to my functions.php file...

add_filter( 'wpv_filter_taxonomy_post_query', 'check_image_field_items', 20, 4 );
function check_image_field_items( $items, $tax_query_settings, $view_settings, $view_id ) {
 
    if( $view_id == 14166) {
        $term_field_slug = 'logo-image';
        $new_items = array();
        for ($i=0; $i < sizeof($items) ; $i++) {
            $field_image = types_render_termmeta( $term_field_slug, array('term_id' => $items[$i]->term_id, 'output' => 'raw') );
            if (!empty($field_image)) {
                $new_items[] = $items[$i];
            }
        }
    }
 
    return $new_items;
}

It works for that particular view and the Manufacturers slider is now great.

But... the function seems to be bleeding over into other Views.(besides View ID 14166)

If I add the code above, it eliminates all of my product categories. Not sure what I am missing

#2320657

I apologize as it was an oversight on my part.

Here is the updated code that should not affect the other views:


add_filter( 'wpv_filter_taxonomy_post_query', 'check_image_field_items', 20, 4 );
function check_image_field_items( $items, $tax_query_settings, $view_settings, $view_id ) {
	if( $view_id == 14166) {
		$term_field_slug = 'logo-image';
		$new_items = array();
		for ($i=0; $i < sizeof($items) ; $i++) {
			$field_image = types_render_termmeta( $term_field_slug, array('term_id' => $items[$i]->term_id, 'output' => 'raw') );
			if (!empty($field_image)) {
				$new_items[] = $items[$i];
			}
		}
		return $new_items;
	}
	else {
		return $items;
	}
}

#2320663

My issue is resolved now. Thank you!

Great support Waqar! Thanks!