Skip Navigation

[Gelöst] What settings do a custom post type need in order for it to be able to relate.

This support ticket is created vor 3 Jahre, 1 Monat. 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 13 Antworten, has 2 Stimmen.

Last updated by henrikG vor 3 Jahre.

Assisted by: Shane.

Author
Artikel
#1965473

Hi support.

I am implementing the PrestoPlayer (hidden link) on my website, and I would like to be able to create a content template for the player.

The player use the block editor and it is REALLY good, but it is not able to use dynamic data so far. I Strongly suggest that toolset get in touch with the developers of presto player and find a way to integrate with toolset because it will open up lots of options for course sites etc.

Presto player has something called a media hub which basically is a custom post type that defines the video settings, so I thought that I could create a one to one relation between a post (or other custom post type) and the custom post type used for the media hub.

But it does not show on the list when I want to create the relation.

So how can I get the media hub post type to show up in the list?

Please see this video that describes what I am trying to do.

hidden link

Cheers.

#1965897

Shane
Supporter

Languages: Englisch (English )

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

Hi Henrik,

Thank you for getting in touch.

The video that you've provided showed a good amount of information that is actually required by our Toolset plugins for the post types to appear.

Mainly I see that the plugin presto player media post type is set "public" settings is set to false. Unfortunately unless the plugin's post type is declared as "public" not necessarily 'publicly queryable'. It just needs to have public set as 'true'.

However what you can do is to remake the post type in our Types plugin, which essentially will bring the post type under Types control.

First you will need to disable the presto player plugin then make the post type. Ensure that the post type is created with the slug "pp_video_block"

Once you've done this please re-activate the presto player plugin and check to see if the post type shows up in the relationship section. Test it to ensure that once you've setup a relationship you can actually set the relationship on the post type.

I've done a quick test on my end for this and it works well.

Thanks,
Shane

#1965931

Ok so you have the player as well.

Let me ask you, how would you go around and get the player settings data set dynamically? Either from a url saved in a custom field, or use a relation to the post type?

The media hub post type can be inserted by a shortcode. like [presto_player id=9249] where the id is the post_id.

Is there an easier way than to overwrite the public settings and relate the media hub record to the post and use a view to get the child record and insert the player somehow?

#1965937

Shane
Supporter

Languages: Englisch (English )

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

Hi Henrik,

I actually downloaded the plugin from the wordpress repository to perform the test on the workaround.

Is there an easier way than to overwrite the public settings and relate the media hub record to the post and use a view to get the child record and insert the player somehow?

Unless it is done through code, the only other way is to bring the post type under Types control as i've mentioned in my previous post.

Let me ask you, how would you go around and get the player settings data set dynamically? Either from a url saved in a custom field, or use a relation to the post type?

Which settings are you referring to ? I'm not too familiar with the plugin so if you can provide a screenshot then I will see if this is something that is possible.

Thanks,
Shane

#1966543

Hi Shane.

I have found a way to insert the player as a shortcode. Its not nice but it will do for now.

I have created a custom field named Presto Video Id and in this field I insert the ID of the media hub

I then create a shortcode in the content template and in the shortcode I write this :

[presto_player id=[types field='presto-video-id' format='FIELD_VALUE'][/types]]

This will insert the video, but since I have no relations to the media post type I have to get the id field manually and its not so nice. But it works.

I seam to remember that earlier, in previous versions of toolset you could actually set a custom post type under toolset's control.
But I cant find those settings anywhere, so I may remember it wrong.

But if only it was possible to enable a custom post type (which are not set to public) as relatable, then I could create a custom field which was a relation to it and it would make it much easier to use the site as a user. Not having to look up the post Id manually.

To be able to relate to a not public post type, would be much better than having to create a shadow post type in types and overwrite the public settings, because that will eventually break the purpose of the plugin developer. And I have spoken to the developer and they do not want the post type to be public to avoid search plugins and seo plugins to index the videos. If the videos are created as private videos.

So it would be nice if I could enable a "hidden" post type in toolset as relatable.

Now about your question, regarding the settings data needed for the player. It is either the url of the video or the ID of the media hub post type.

#1966903

Shane
Supporter

Languages: Englisch (English )

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

Hi Henrik,

Happy to see that you've made some progress on this, however addressing your queries below.
I seam to remember that earlier, in previous versions of toolset you could actually set a custom post type under toolset's control.
But I cant find those settings anywhere, so I may remember it wrong.

I actually addressed how to do this in my previous post. This is how we can now establish a relationship between the Toolset custom post type and the Media hub post type.

https://toolset.com/forums/topic/what-settings-do-a-custom-post-type-need-in-order-for-it-to-be-able-to-relate/#post-1965897

If you take another look at my post above it should address your issue because in my testing I was able to setup the post with a relationship and it works well.

Please perform the steps in my instructions and let me know if you are able to get the same results.

Thanks,
Shane

#1966947

Hi Shane.

I was able to make that work yes. But it messed up the menu structure of the prestoplayer hub and also my seo plugin was now able to index the presto media post type. So its a hack and it will probably break the future updates of Prestoplayer.

I prefer not to hack the system like that.

So Now I would like to remove that hack, but without loosing data. If I delete the "hack" post type I created in toolset, will it also delete the post data?

#1966989

Shane
Supporter

Languages: Englisch (English )

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

Hi Henrik,

Unfortunately there isn't much we can do about this given the requirements of Toolset where the post type must be set to be public. If it isn't we won't be able to query it to setup the relationships etc.

However checking in the settings you can disable the additional menu item by going to the Media Hub post type you've created and disable, show_in_menu under the options settings.

Furthermore you can set your SEO plugin not to index this post type. If you are using Yoast you can go to SEO -> Search Appearance and set both "Show Media Hub in search results?" and "Show SEO settings for Media Hub" to no.

Apart from this workaround not much else we can do to get this working for you. Essentially this workaround exists for scenarios like this as well.

Thanks,
Shane

#1967179

I got this snippet from the developers of prestoplayer. It only changes the public setting, which I think is a wiser choice.

So I will put this code into a toolset functions under settings and use that to change the public settings for the post type to true, and then go to my SEO plugin and deactivate the Media block.

I believe that is more safe than overwriting all settings with a custom post type created in toolset, since it only changes one parameter for the post type.

function wp1482371_custom_post_type_args($args, $post_type)
{
    if ("pp_video_block" === $post_type) {
        $args['public'] = true;
    }

    return $args;
}
add_filter('register_post_type_args', 'wp1482371_custom_post_type_args', 20, 2);

#1967201

Shane
Supporter

Languages: Englisch (English )

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

Hi Henrik,

Happy that the developers of prestoplayer plugin was able to provide a workaround for this.

Given that the post type has now been declared as public you will now be able to add the post type in a relationship. If there are any issues please let me know.

If not then you can go ahead and close here.
Thanks,
Shane

#1967441

Shane, if I put the snippet code in the custom code section in toolset / settings it does not work.

If I put the same code inside functions.php or a plugin it works fine.

Its like the toolset / settings custom code is not executed, and YES I have activated the code.

Please watch this video : hidden link

Cheers.

#1967509

Shane
Supporter

Languages: Englisch (English )

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

Hi Henrik,

Initially I was led to believe this had to do with the Load priority of the snippets, however creating a custom snippet as a sample and testing with our Custom code section and another plugin I found that the issue still remains.

I went ahead and escalated the ticket to our 2nd tier supporters, however i'm not expecting a speedy response as we are short staffed due to vacations at the moment.

As soon as I get a response I will let you know the progress on this.

Though this shouldn't prevent you from continuing your work as the code works in the functions.php file. Once we identify the issue you can simply just transfer the snippet to the Toolset custom code section.

Thanks,
Shane

#1967903

Shane
Supporter

Languages: Englisch (English )

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

Hi Henrik,

I've gotten some feedback on this one for you. Here is the reference link below.
https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/?utm_source=plugin&utm_medium=gui&utm_campaign=toolset#snippet-execution-timing

As suspected it has to do with the load priority of the custom snippets and when the many to many relationships are loaded. What this means is that you will need to modify the post type's public settings Before it is loaded by our plugin. In this case using the custom code snippets will be loaded After the post type has been requested.

We cannot load the snippet with a priority less than 20 due to when the entire snippets package is loaded.

In such a case where you need it to run before the post type is loaded you will need to add it to the functions.php file.

Please let me know if this clarifies the issue for you.
Thanks,
Shane

#1969757

I understand the problems with the priority.

I would be nice to get some feedback, from the software instead of just nothing happens. But I can't imagine how this should be done, if its not possible to lower the priority and test it?

Perhaps the best solution is to mention this in the description. That if your snippet does not appear to work, try to implement it in functions.php due to priority issues or something like that 🙂

Anyway thanks for your help.

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