Get the list of all media from wordpress.com site
I want to get the list of all media in my wordpress site via REST API. Based on what I found in Wordpress REST API doc I am using the following GET url but its not working. https://xxx.wordpress.com/wp-json/wp/v2/media
Instead of a JSON response, i am getting an HTML page that says Oops! That page can’t be found.
wordpress
add a comment |
I want to get the list of all media in my wordpress site via REST API. Based on what I found in Wordpress REST API doc I am using the following GET url but its not working. https://xxx.wordpress.com/wp-json/wp/v2/media
Instead of a JSON response, i am getting an HTML page that says Oops! That page can’t be found.
wordpress
What URL are you actually using? If you're using thexxx.wordpress.com
, you need to replace that with YOUR URL.
– disinfor
Nov 28 '18 at 16:58
add a comment |
I want to get the list of all media in my wordpress site via REST API. Based on what I found in Wordpress REST API doc I am using the following GET url but its not working. https://xxx.wordpress.com/wp-json/wp/v2/media
Instead of a JSON response, i am getting an HTML page that says Oops! That page can’t be found.
wordpress
I want to get the list of all media in my wordpress site via REST API. Based on what I found in Wordpress REST API doc I am using the following GET url but its not working. https://xxx.wordpress.com/wp-json/wp/v2/media
Instead of a JSON response, i am getting an HTML page that says Oops! That page can’t be found.
wordpress
wordpress
edited Nov 29 '18 at 18:00
DACrosby
8,32132541
8,32132541
asked Nov 27 '18 at 20:44
Irshad MohamedIrshad Mohamed
824914
824914
What URL are you actually using? If you're using thexxx.wordpress.com
, you need to replace that with YOUR URL.
– disinfor
Nov 28 '18 at 16:58
add a comment |
What URL are you actually using? If you're using thexxx.wordpress.com
, you need to replace that with YOUR URL.
– disinfor
Nov 28 '18 at 16:58
What URL are you actually using? If you're using the
xxx.wordpress.com
, you need to replace that with YOUR URL.– disinfor
Nov 28 '18 at 16:58
What URL are you actually using? If you're using the
xxx.wordpress.com
, you need to replace that with YOUR URL.– disinfor
Nov 28 '18 at 16:58
add a comment |
2 Answers
2
active
oldest
votes
Assuming your site is on wordpress.com (notably different from wordpress.org's self hosted version), you're using the wrong API documentation. You actually want to use the WordPress.com API Docs.
Specifically for getting all media items, you'll use the following:
https://public-api.wordpress.com/rest/v1.1/sites/$site/media/
where $site is "your-site.wordpress.com"
Related docs
Even the wordpress support didn't give such a clear answer. +100
– Irshad Mohamed
Nov 29 '18 at 1:55
add a comment |
Using the following code you can get all the attachments. However , you would need access to WordPress theme to run the PHP script.
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => - 1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image ) {
$title = get_the_title( $image->ID );
$images = wp_get_attachment_url( $image->ID );
$caption = wp_get_attachment_caption( $image->ID );
$attachment = get_post( $image->ID );
$description = $attachment->post_content;
}
If you are not able to run the PHP script inside WordPress , then you have to:
1 - Get the attachment ID through /wp-json/wp/v2/media/
2 - Get the attachment info through /wp-json/wp/v2/media/attachment_ID
This the documentation: https://v2.wp-api.org/reference/media/
Regards.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53507844%2fget-the-list-of-all-media-from-wordpress-com-site%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Assuming your site is on wordpress.com (notably different from wordpress.org's self hosted version), you're using the wrong API documentation. You actually want to use the WordPress.com API Docs.
Specifically for getting all media items, you'll use the following:
https://public-api.wordpress.com/rest/v1.1/sites/$site/media/
where $site is "your-site.wordpress.com"
Related docs
Even the wordpress support didn't give such a clear answer. +100
– Irshad Mohamed
Nov 29 '18 at 1:55
add a comment |
Assuming your site is on wordpress.com (notably different from wordpress.org's self hosted version), you're using the wrong API documentation. You actually want to use the WordPress.com API Docs.
Specifically for getting all media items, you'll use the following:
https://public-api.wordpress.com/rest/v1.1/sites/$site/media/
where $site is "your-site.wordpress.com"
Related docs
Even the wordpress support didn't give such a clear answer. +100
– Irshad Mohamed
Nov 29 '18 at 1:55
add a comment |
Assuming your site is on wordpress.com (notably different from wordpress.org's self hosted version), you're using the wrong API documentation. You actually want to use the WordPress.com API Docs.
Specifically for getting all media items, you'll use the following:
https://public-api.wordpress.com/rest/v1.1/sites/$site/media/
where $site is "your-site.wordpress.com"
Related docs
Assuming your site is on wordpress.com (notably different from wordpress.org's self hosted version), you're using the wrong API documentation. You actually want to use the WordPress.com API Docs.
Specifically for getting all media items, you'll use the following:
https://public-api.wordpress.com/rest/v1.1/sites/$site/media/
where $site is "your-site.wordpress.com"
Related docs
answered Nov 28 '18 at 20:05
DACrosbyDACrosby
8,32132541
8,32132541
Even the wordpress support didn't give such a clear answer. +100
– Irshad Mohamed
Nov 29 '18 at 1:55
add a comment |
Even the wordpress support didn't give such a clear answer. +100
– Irshad Mohamed
Nov 29 '18 at 1:55
Even the wordpress support didn't give such a clear answer. +100
– Irshad Mohamed
Nov 29 '18 at 1:55
Even the wordpress support didn't give such a clear answer. +100
– Irshad Mohamed
Nov 29 '18 at 1:55
add a comment |
Using the following code you can get all the attachments. However , you would need access to WordPress theme to run the PHP script.
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => - 1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image ) {
$title = get_the_title( $image->ID );
$images = wp_get_attachment_url( $image->ID );
$caption = wp_get_attachment_caption( $image->ID );
$attachment = get_post( $image->ID );
$description = $attachment->post_content;
}
If you are not able to run the PHP script inside WordPress , then you have to:
1 - Get the attachment ID through /wp-json/wp/v2/media/
2 - Get the attachment info through /wp-json/wp/v2/media/attachment_ID
This the documentation: https://v2.wp-api.org/reference/media/
Regards.
add a comment |
Using the following code you can get all the attachments. However , you would need access to WordPress theme to run the PHP script.
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => - 1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image ) {
$title = get_the_title( $image->ID );
$images = wp_get_attachment_url( $image->ID );
$caption = wp_get_attachment_caption( $image->ID );
$attachment = get_post( $image->ID );
$description = $attachment->post_content;
}
If you are not able to run the PHP script inside WordPress , then you have to:
1 - Get the attachment ID through /wp-json/wp/v2/media/
2 - Get the attachment info through /wp-json/wp/v2/media/attachment_ID
This the documentation: https://v2.wp-api.org/reference/media/
Regards.
add a comment |
Using the following code you can get all the attachments. However , you would need access to WordPress theme to run the PHP script.
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => - 1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image ) {
$title = get_the_title( $image->ID );
$images = wp_get_attachment_url( $image->ID );
$caption = wp_get_attachment_caption( $image->ID );
$attachment = get_post( $image->ID );
$description = $attachment->post_content;
}
If you are not able to run the PHP script inside WordPress , then you have to:
1 - Get the attachment ID through /wp-json/wp/v2/media/
2 - Get the attachment info through /wp-json/wp/v2/media/attachment_ID
This the documentation: https://v2.wp-api.org/reference/media/
Regards.
Using the following code you can get all the attachments. However , you would need access to WordPress theme to run the PHP script.
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => - 1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image ) {
$title = get_the_title( $image->ID );
$images = wp_get_attachment_url( $image->ID );
$caption = wp_get_attachment_caption( $image->ID );
$attachment = get_post( $image->ID );
$description = $attachment->post_content;
}
If you are not able to run the PHP script inside WordPress , then you have to:
1 - Get the attachment ID through /wp-json/wp/v2/media/
2 - Get the attachment info through /wp-json/wp/v2/media/attachment_ID
This the documentation: https://v2.wp-api.org/reference/media/
Regards.
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => - 1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image ) {
$title = get_the_title( $image->ID );
$images = wp_get_attachment_url( $image->ID );
$caption = wp_get_attachment_caption( $image->ID );
$attachment = get_post( $image->ID );
$description = $attachment->post_content;
}
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => - 1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image ) {
$title = get_the_title( $image->ID );
$images = wp_get_attachment_url( $image->ID );
$caption = wp_get_attachment_caption( $image->ID );
$attachment = get_post( $image->ID );
$description = $attachment->post_content;
}
answered Nov 28 '18 at 2:34
Eduardo Estevez NuñezEduardo Estevez Nuñez
1054
1054
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53507844%2fget-the-list-of-all-media-from-wordpress-com-site%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What URL are you actually using? If you're using the
xxx.wordpress.com
, you need to replace that with YOUR URL.– disinfor
Nov 28 '18 at 16:58