I am working on a WordPress gallery website which has only three pages: Home, Gallery, and Bio (http://adamgreener.com/).
When you click Bio, the Bio content pops up, powered by Easy Modal plugin (the content is manually typed in HTML in the plugin settings).
I also have the exact same HTML content in a WordPress page (which mobile viewers see, rather than a popup).
The page is very simple to edit, but the Modal content is not so friendly to the average user. I am seeking a way that I can allow the user to edit only the Bio page, and have that modal content update at the same time.
What would be the best route for such an action?
Thanks in advance!
You could use
get_page
to get the page content, and a shortcode to display it in the popup. In thefunctions.php
file of your WordPress theme, e.g.:Then, in your modal, use the shortcode:
[greener_bio]
There are two possible ways to accomplish what you’re going for, both described in depth in my blog post: https://allurewebsolutions.com/open-wordpress-post-modal-without-plugin
You can also just use my plugin for this: https://wordpress.org/plugins/wp-post-modal/
First Method
The first method requires modifying the template that serves the content you want to appear in the modal. For example, you have a template called
modal-content-template.php
.Inside that template we wrap the content we want loaded into the modal with:
Full example of a template where we are excluding the WordPress header and footer:
CodePen example for the JS required to make this work
Second Method
The second method is a little more elegant. We use the
modalContent.load(post_link + ' #modal-ready');
method to load the modal content.The modal contact is wrapped in a wrapper container with ID
#modal-ready
. This can be done without even touching the page template using a function that hooks into the content.