Skip to main content
21 events
when toggle format what by license comment
Jul 27, 2017 at 7:09 comment added vinay I have changed permalink,, but still im nt able to display anything. example.com/?rest_route=/vinay/ajax-blog this link also not showing any blog posts
Jul 27, 2017 at 6:38 comment added Johansson Yes they will. But if you don't want to change them, you can use this instead: https://example.com/?rest_route=/vinay/ajax-blog. Does the same when you have plain permalinks.
Jul 27, 2017 at 6:34 comment added vinay yes sir i hve changed example to my domainname... if i change permalink,, then url of my existing website will be changed??
Jul 27, 2017 at 6:26 comment added Johansson I assume you have changed the example with your domain. Also, you need to change the permalink structure from Settings > Permalink to anything other than plain.
Jul 27, 2017 at 6:25 comment added vinay When Im trying to access->example.com/wp-json/vinay/ajax-blog........................ im getting 404 error Not Found The requested document was not found on this server.
Jul 27, 2017 at 6:11 comment added Johansson Enjoy it :) and let me know if you had any more problem.
Jul 27, 2017 at 6:11 history edited Johansson CC BY-SA 3.0
deleted 76 characters in body
Jul 27, 2017 at 6:09 comment added Johansson Yes, you should do it in blog/wp-content/themes/superior/functions.php. You should never modify any file outside wp-content (except wp-config.php in some situations)
Jul 27, 2017 at 6:06 comment added vinay functions.php is in blog/wp-content/themes/superior/functions.php............ so do i need to make changes in this path or i have to create a new functions.php in wp-json folder???
Jul 27, 2017 at 6:02 history edited Johansson CC BY-SA 3.0
added 80 characters in body
Jul 27, 2017 at 5:44 comment added Johansson I've also updated the answer for you. Make sure you have jQuery loaded though :) @vinay
Jul 27, 2017 at 5:44 history edited Johansson CC BY-SA 3.0
added 250 characters in body
Jul 27, 2017 at 5:39 comment added Johansson 1) After adding the code to your theme's functions.php, try to access http://example.com/wp-json/vinay/ajax-blog. if you see the result in text without errors, then it's good. 2) remove the code in your HTML file and only add this <section id="blog"><div id="container-div"></div></section> to it (also the jQuery script I wrote). The jQuery script will automatically fetch your posts from WordPress and add it to the <div id="container-div"></div>. don't forget to change example.com to your domain :)
Jul 27, 2017 at 5:25 comment added vinay Thank u sir,, but one more query............. i have to remove my code or with that code i hve to add the script?????????????? and do i need to make changes in the script like url and others.......... as im new to jquery plz help me to make changes....
Jul 26, 2017 at 20:00 history edited Johansson CC BY-SA 3.0
added 29 characters in body
Jul 26, 2017 at 20:00 comment added Johansson You're welcome! All the PHP goes in your WordPress theme's functions.php file, and the JavaScript goes in the bottom of your HTML template (not WordPress).
Jul 26, 2017 at 12:33 comment added vinay Thank u sir... a small doubt.. callback function-> where i need to add.. and should i create wp-json folder containing vinay and ajax-blog folders?????????? and where i have to add last code.. Plz i need full details where to add the code..
Jul 26, 2017 at 12:33 vote accept vinay
Jul 26, 2017 at 12:33
Jul 26, 2017 at 12:21 comment added Stender This is a better way.
Jul 26, 2017 at 12:06 history edited Johansson CC BY-SA 3.0
added 32 characters in body
Jul 26, 2017 at 12:00 history answered Johansson CC BY-SA 3.0