Skip Navigation

[Gelöst] using custom fields with Divi builder .. single view post

This support ticket is created vor 1 Jahr, 11 Monate. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 10 Antworten, has 2 Stimmen.

Last updated by Shane vor 1 Jahr, 11 Monate.

Assisted by: Shane.

Author
Artikel
#2340505
2022-04-13_15-33-35.jpg

This is the website I'm working on:

hidden link

I have added custom fields to the posts for media coverage and speeches taxonomy.

For post types within those taxonomies where there is custom field data for that post I'm trying to get the content to show in one of two ways:

With Divi
I learned from a previous help topic to wrap my wp types code:

{!{types field='linked-file' output='raw'}!}{!{/types}!}

I have three data fields:
A file: linked-file
A single line: linked-file-name
A single line: linked-notes

And it no longer seems to work for the URL and Notes fields. It does output the name field.

. . . .

MY PREFERRED WAY:
I'd prefer to do this with the Blocks Builder so that I can conditionally hide the content if there is no file linked.

I've used a conditional 'if field' to wrap around showing a button, title with a link to a document and the notes fields. All of which are custom field data, same as written above. The logic is: If the linked-file is NOT empy show the following: URL active button, URL active name and static notes text.

Within the view I have set the View to display posts, and then Filter by post relationship or repeatable fields group owner, where the content comes from The post where this View is shown.

However as you can see 'no items found' yet the divi version shows the results clearly.

Can you help?
Thanks
Cathie

#2340553

Shane
Supporter

Languages: Englisch (English )

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

Hi Cathie,

Thank you for getting in touch.

Within the view I have set the View to display posts, and then Filter by post relationship or repeatable fields group owner, where the content comes from The post where this View is shown.

However as you can see 'no items found' yet the divi version shows the results clearly.

Based on what I see from your screenshot your Post is not in a relationship created with Toolset because there is a notice on the relationship filter.

Was a relationship setup between your Posts and another post type ? Can you send me a screenshot of your Toolset -> Post Relationship screen?

Finally if you remove this Relationship filter does the view start showing your posts?

Please let me know.
Thanks,
Shane

#2340597

Hi Shane .. I've removed the relationship filter and now nothing shows up at all. I hadn't created a relationship I just wanted the view to pull in content from the current post where there view is shown.

Thanks
Cathie

#2340707

Shane
Supporter

Languages: Englisch (English )

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

Hi Cathie,

Would you mind allowing me to have admin access to the website so that I can have a more detailed look at this for you ?

Please where applicable please provide me with a link to an example page where I can see the issue.

I've enabled the private fields for your next response.

Thanks,
Shane

#2344535

Hi there, I hope you're still able to help me?
Thanks
Cathie

#2344601

Shane
Supporter

Languages: Englisch (English )

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

Hi Cathie,

I'm currently having a look at his one for you.

The reason why your view isn't displaying anything is because your view isn't filtering for the current post.

I've added the Post ID query filter to your view and set it to get the id from the shortcode parameter "ids".

What you need to now do is go to the template where you're adding the view's shortcode and add the attribute ids="[wpv-post-id]"

Please let me know if this helps.
Thanks,
Shane

#2344645

So when I'm using a shortcode to call up the view I should put it like this?

[wpv-view name="Press Media Document Link" attribute ids="[wpv-post-id]"]

the problem with the above is the last "] is output as text and the view fails and outputs a result 'no items found'.

hidden link

#2344725

Shane
Supporter

Languages: Englisch (English )

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

Hi Cathie,

Can you send me a direct link to edit the template for this posts?

I suspect the issue is that divi builder isn't able to process the nested shortcode so we would need to have a look at filtering the view through a hook.

Please send me the link for the edit template page for the template that is being used on your posts.

Thanks,
Shane

#2345063
2022-04-20_09-29-30.jpg

Hi,

This is the divi theme builder and its the third box on the top for 'all posts'.

hidden link

That's where I'm using a code block to use shortcode to pull through the view.

This is the view itself that is being called, that you helped edit to add the filter by ID's.

hidden link

Thank you,
Cathie.

#2345115

You can see the 'speech' does have a document attached in the custom fields.

hidden link

Just in case you wanted to double check it.

#2345321

Shane
Supporter

Languages: Englisch (English )

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

Hi Cathie,

Please modify the shortcode and remove the the ids parameter from your view shortcode.

Then add the following to your site's functions.php file.

add_filter( 'wpv_filter_query', 'filter_basedon_page', 10, 3 );
  
function filter_basedon_page( $query, $settings, $view_id ) {
   $postid = get_the_ID();
    if ( $view_id == 5635 ) {
       $query['post__in']= array($postid);                          
    }
    return $query;
}

Replace 5635 with the ID of your view. Unfortunately i'm not able to add this to your functions.php file as it seems I require FTP access to make this change.

Please try this code and let me know if it works.

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.