Enrich WordPress content with data from the OpenPublishing services
- Install using the WordPress built-in Plugin installer, or clone repository and drop the contents in the
wp-content/plugins/openpublishing
directory of your WordPress installation. - Activate the plugin through the 'Plugins' menu in WordPress.
- Go to Open Publishing settings on left menu bar
- Proceed with further instructions: set realm id, token and API host.
To visualize Open Publishing data on your page please use smart substitution tags in place you want to insert a data, like so [large_document_view:document.123]
or [sidebar:newest.1:de]
This substitution tag will be replaced by the data this plugin retrieve from OP server.
Smart substitution notation contain: [ "tag_name":"object"."object_id":"language" ]
language
is an optional parameter, use it to get language specific results. Possible values: en
, de
, fr
, es
.
You can use: document
, bestseller
, newest
, most_read
objects.
To make this work please create templates for each tag_name you would like to use. You can do this in two different ways.
-
Using Elementor plugin:
- Go to Elementor page
- Create new template, remember a template id (you can see it in the edit url)
- You can easily style your template by means of Elementor
-
Using WordPress posts:
- Go to Pages > Add New
- Create new post and treat it like a template, remember a template id (you can see it in the edit url)
- (Optional) you can assign special category (like op-templates) to each post to distinguish between others
- Use special keywords in your template:
{title} {subtitle} {price} {grin_url} {source_url} {document_id} {cdn_host} {realm_id}
Add newly created templates/posts on this page with corresponding ids.
To use substitution please insert into your page this tag with desired 'tag_name' and 'object_id' like:
<h2>Our bestsellers:</h2>
<div>[large_document_view:bestseller.1] [large_document_view:bestseller.2] [large_document_view:bestseller.3]</div>
This tags should be replaced right away.
To debug plugin work please add next code into your page after all text:
<script type="text/javascript">
var debug = document.getElementsByClassName("OP_debug");
for(i=0; i<debug.length; i++) { debug[i].style.display = 'inline'; }
</script>
This will allow you to see some more information about substitution.