-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME_js
39 lines (23 loc) · 1.57 KB
/
README_js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
## WP JSON API Plugin (Javascript Client example)
## Builds a wordpress site in pure javascript, with ability to view posts by categories (all on a single page).
Takes the hassle out of handling XHR requests and parsing wordpress data.
Makes two XHR calls, does not use jquery.
Basic Usage:
Simply put the page somewhere on your wordpress site and provide a url to the wordpress blog (to build the
api queries for the plugin).
Make links like:
<a href="#" onclick="wp_build_post('?json=- your query with params-')">Link</a>
To issue an additional XHR request and rebuild the 'content' div.
## Example of this is inside of function wp_build_categories()
Useful functions:
wp_build_posts() - this builds posts. Pass it a url like ?json=<function>¶m1=value1, it'll make a xhr call
and update the content div (only) change the body onload param to modify what gets show initially
_tag() - just a little connivence function that assembles html, haven't decided how much I like it versus
writing html like 'normal'
ToDo:
Implement pages/links/tags. Should not be hard with function wp_build_posts(). Reuse XHR requests to
only use one at a time.
Speed it up?
Obviously enter any static data as html (categories/links/pages) - as those fields do not change often,
cache a json response to a file to load instead of hitting the API all of the time - which seems to be
as intensive (maybe less) than a real wordpress site.