I'm trying to be able to fetch all the posts of a particular post type on my website. The post type should be called 'opportunities'. I'm new to wordpress so a bit out of my depth. The posts in question actually have their on button on the admin sidebar so they could be something entirely different from a 'custom_post_type'. Any help I could get on this would be much appreciated.
*edit: These are the notes I got from a developer I'm trying to help:
"To access the database with opportunities from the UK office we need them to make these available through an API. This can be done by their developer by changing a few lines in their code. It’s explained at: / after making the changes I need to know the URL where I can retrieve the opportunities through JSON."
I'm not a developer, I'm more or less just the guy that got asked to help with website in our office.
I'm trying to be able to fetch all the posts of a particular post type on my website. The post type should be called 'opportunities'. I'm new to wordpress so a bit out of my depth. The posts in question actually have their on button on the admin sidebar so they could be something entirely different from a 'custom_post_type'. Any help I could get on this would be much appreciated.
*edit: These are the notes I got from a developer I'm trying to help:
"To access the database with opportunities from the UK office we need them to make these available through an API. This can be done by their developer by changing a few lines in their code. It’s explained at: https://developer.wordpress/rest-api/extending-the-rest-api/adding-rest-api-support-for-custom-content-types/ after making the changes I need to know the URL where I can retrieve the opportunities through JSON."
I'm not a developer, I'm more or less just the guy that got asked to help with website in our office.
I think what you mean is do an onclick event.
So, you can do this with JavaScript. Create your link as per usual <a id=“myCustomLink” href=“#” onclick=“MyFunction();return false;”>huh! I’m a link!</a>
And now some script
<script>
function MyFunction() {
//Make it do whatever here! For example:
document.getElementById("demo").innerHTML = "Hello World";
}
</script>
Rerun false;
will prevent the browser directing to the link... unless you want it to? If so then just remove this and add a link in-place of the # after the href.
However! A much cleaner way of doing this would be to do it as JQuery and attach the ID as an onclick handler. Like so:
$(‘#myLink’).click(function(){ MyFunction(); return false; });
Hope this helps!
'show_in_rest' => true
and'rest_controller_class' => 'WP_REST_Posts_Controller'
parameters while registering your post typeopportunities
? If yes the you can access them with rest api endpoint like: example/wp-json/wp/v2/opportunities – maheshwaghmare Commented Oct 26, 2018 at 14:06http://yoursite
with your domain and try yourself. It'll works! If not then share your website URL for reference. – maheshwaghmare Commented Oct 26, 2018 at 14:07