0

i am trying to get the html code of the description of a few themes from WordPress, i know this is possible to achieve in codecanyon, but can't get the hang of it in wordpress.org, i've read the api.wordpress.org documentation of theme and plugin section at https://codex.wordpress.org/WordPress.org_API and was able to achieve this with plugins https://api.wordpress.org/plugins/info/1.0/{slug}.json, but themes aren't as clear. Can someone please help me out?

1 Answer 1

1

If you're in the admin site you can use themes_api()

$info = themes_api( 'theme_information', [ 'slug' => 'twentyten' ] );
echo esc_textarea( $info->sections['description'] );

but that's plain text, not HTML. The API request it generates is

https://api.wordpress.org/themes/info/1.2/?action=theme_information&request%5Bslug%5D=twentyten&request%5Blocale%5D=en_US&request%5Bwp_version%5D=5.3.2

You can see the parameters in there as multiple URL-encoded request[key] parameters.

2
  • 1
    It should be $info->sections, not $info['section'] .. :)
    – Sally CJ
    Mar 21, 2020 at 12:00
  • 1
    @SallyCJ Oops, yes. Thanks!
    – Rup
    Mar 21, 2020 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.