wp_enqueue_style built in styles

I’m a little confused by your question, can you not simply use wp_enqueue_style, which you actually wrote into this threads heading(not sure if you know the function exists or not). wp_enqueue_style works in the same way as the wp_enqueue_script counterpart, but of course as you’d expect, enqueues stylesheets.. Here’s a list of the enqueues i … Read more

Count posts returned by get_posts in external PHP script

The WordPress function get_posts() is making it’s own instance of WP_Query that is not globally accessible: function get_posts($args = null) { // … cut … $get_posts = new WP_Query; return $get_posts->query($r); } so you could instead try $results = get_posts($args); echo count($results); to give you the array count of post objects returned by get_posts(). WP_Query() … Read more

WP API Get post with tag names instead of tag ID’s

I figured something out based on what I found at this post. Basically I need a plugin that listens for when the REST response is about to go out. The plugin code would be similar to the following: function ag_filter_post_json($response, $post, $context) { $tags = wp_get_post_tags($post->ID); $response->data[‘tag_names’] = []; foreach ($tags as $tag) { $response->data[‘tag_names’][] … Read more

fetching via fetch/ajax gutenberg block data from third party

Well, I figured it out. Though my solution is probably far from elegant (I’m not making concessions for timeouts or usability/accessibility). My problem was mostly overzealous configuration, copy and paste errors, and needing to apply async/await keywords. Attributes look like this: attributes: { url: { source: ‘attribute’, type: ‘string’, selector: ‘.o_microlink’, attribute: ‘href’, }, title: … Read more

Creating external apps WordPress / How they work

WordPress features a very rich XML-RPC interface that you can work with from external applications. It provides you access to most of the functionality you’d have directly in the admin – write posts, edit posts, edit comments, create/edit categories, manage site options, upload files, etc. As a matter of fact, certain third-party applications are already … Read more

WordPress API – count posts

Assuming you are using Linux or OS X, the easiest way is probably to use wp-cli (if present in your WordPress installation) to return a list of all posts: wp-cli post list Then pipe it to the word count tool to get the number of lines: wc -l Finally, deduct one to take care of … Read more

Does the WordPress API have Modal Dialogs

Yes, WordPress has modal dialog and it is called as Thickbox, but I am not sure how flexible it is to implement what you want to. Here is the code – <?php add_thickbox(); ?> <div id=”my-content-id” style=”display:none;”> <p> This is my hidden content! It will appear in ThickBox when the link is clicked. </p> </div> … Read more

get_userdata by username

get_userdata() function is an alias of get_user_by(‘ID’) function. Use this code: $username=”your user name”; $user = get_user_by(‘login’, $username); It will return WP_User object on success, or false on failure. See Codex. REST API: http://example.com/wp-json/wp/v2/users/<id>