We have a portfolio of custom post entries that have various elements like text and image. A few of these elements are are being displayed in a loop (created with Views) on an overview page. This is fine an no problem for us.
The desired (special) functionality:
Each custom post overview entry shall contain a link (button) that shall open a popup (modal) in which all elements of the respective custom post will be displayed via a template.
We are using Elementor page builder on the website, so the desired way to implement this function would be to create a template for the modal/popup with Elementor and use the shortcode of this template.
The challenges/questions for us are:
How shall the code for the link look like to call the content of this specific custom post entry in a modal popup?
I assume we need to insert a kind of ID or other identifier (for the custom post entry) to the link, so that the link/button calls the right post entry content to insert it into the modal template.
Correct?
Any help and tip to solve this is very appreciated!
Each custom post overview entry shall contain a link (button) that shall open a popup (modal) in which all elements of the respective custom post will be displayed via a template.
Hello, to some extent it depends on how these elements are rendered in the custom post single page. For example, if you use a Toolset Content Template to render the single post page for these custom posts and display things like the post body, custom fields, and taxonomy terms, then normally you would want to display that same Content Template in the modal and pass in the post ID using shortcode attributes like so:
[wpv-post-body view_template="your-template-slug" item="12345"]
You would replace your-template-slug with the slug of the desired Content Template, and replace 12345 with the ID of the post you wish to display. That's the normal process for displaying a rendered Content Template outside of its assigned location. However, I'm not exactly sure if this will work in an Elementor modal because Toolset's Content Templates and Elementor's templates are often incompatible for technical reasons. Applying Elementor templates and Toolset Content Templates to the same content can have unexpected results, including nothing at all appearing on the front-end of the site.
So it's something you could experiment with, but it's not a guaranteed solution. Other shortcodes are available for displaying post content in an Elementor template. For example, Types custom fields can be displayed using a shortcode API:
https://toolset.com/documentation/customizing-sites-using-php/functions/
Other Views shortcodes are available as well for information like the post title, post ID, post author, taxonomy terms, etc.:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/
I might be able to offer more guidance if you provide a bit more information about what you want to display in the modal.