Adding Monarch plugin to stand alone PHP script emulating WordPress layout

88 views Asked by At

I'm putting together a WordPress site for a charity organization which upgrades the look & feel of their existing site. Their existing site had a few PHP scripts and an events database for their project listings and I changed the output so that the script emulates the WordPress UI using:

    define( 'WP_USE_THEMES', true );
    require_once "wp-load.php";

The site uses the Monarch social plugin to enable sharing and I need to have that work on the emulated project page.

I haven't been able to find what I should include.

I tried adding both of these lines, separately, but they had no affect:

    require_once "wp-content/plugins/monarch/monarch.php";
    require_once "wp-content/plugins/monarch/core/init.php";

Upon looking at the code and trying to call functions that looked like potential functions to execute it, they resulted in an error or does nothing.

1

There are 1 answers

0
Phil On BEST ANSWER

As someone completely unfamiliar with the intricacies of WordPress doing a pro bono favor for a charity organization, I did not realize that page templates could be used as the destination for custom PHP code accessing a non-WordPress database, etc.

The solution steps (which may hopefully help someone else equally unaware of WordPress) are as follows:

  • Use the page template page as reference to create a page template.
  • I added my page template to the same location as the theme's page.php template
  • Then create a page in WordPress and specify its template as the one just created.
  • Call that new page with whatever parameters after ?xyz=value;abc=etc. as needed

This may be basic for people who live in WordPress but it wasn't immediately clear to me.

Thanks to the comments by @ChrisHaas!