Get the list of all media from wordpress.com site












0















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.










share|improve this question

























  • 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
















0















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.










share|improve this question

























  • 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














0












0








0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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

















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












2 Answers
2






active

oldest

votes


















1














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






share|improve this answer
























  • Even the wordpress support didn't give such a clear answer. +100

    – Irshad Mohamed
    Nov 29 '18 at 1:55





















-1














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.






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    1














    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






    share|improve this answer
























    • Even the wordpress support didn't give such a clear answer. +100

      – Irshad Mohamed
      Nov 29 '18 at 1:55


















    1














    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






    share|improve this answer
























    • Even the wordpress support didn't give such a clear answer. +100

      – Irshad Mohamed
      Nov 29 '18 at 1:55
















    1












    1








    1







    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






    share|improve this answer













    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







    share|improve this answer












    share|improve this answer



    share|improve this answer










    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





















    • 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















    -1














    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.






    share|improve this answer




























      -1














      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.






      share|improve this answer


























        -1












        -1








        -1







        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.






        share|improve this answer













        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;

        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 28 '18 at 2:34









        Eduardo Estevez NuñezEduardo Estevez Nuñez

        1054




        1054






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks