Create an article from another Java application

Yes, there is a REST API at /wp-json with core content endpoints for posts pages etc For example, my current latest blog post: https://tomjn.com/2018/07/23/deployment-and-wordpress/ Is available via a GET request as a JSON object at: https://tomjn.com/wp-json/wp/v2/posts/862 And I can send a similar object via an authenticated POST request to create a new post to https://tomjn.com/wp-json/wp/v2/posts/, … Read more

How do I add a custom body class to the admin area of a page?

Use admin_body_class both with global post_id and get_current_screen function: add_filter(‘admin_body_class’, ‘wpse_320244_admin_body_class’); function wpse_320244_admin_body_class($classes) { global $post; // get_current_screen() returns object with current admin screen // @link https://codex.wordpress.org/Function_Reference/get_current_screen $current_screen = get_current_screen(); if($current_screen->base === “post” && absint($post->ID) === 8) { $classes .= ‘ home-admin-area’; } return $classes; } You can also use $pagenow variable. It seems that … Read more

Unwanted Duplicate Posts Showing in Pagination Pages

Try with a custom WP_Query to rule out any possible code messing up with your main query pagination. Like this: <?php $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $query = new WP_Query( array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 5, ‘paged’=> $paged) ); ?> <?php while($query->have_posts()) : … Read more

How many post WordPress can handle?

There isn’t a hard upper limit of how many posts WordPress can handle. The practical limit for your site depends on these things in this order: The queries your codebase runs Server power Disk space But before we go into this, WP will not generate 404’s because there are too many posts. If this is … Read more

Get post id in wordpress action?

I haven’t tested so I’m providing you with two possibilities, Inside a loop, use the following: $post_id = get_the_ID(); Outside a loop, use the following: global $wp_query; $post_id = $wp_query->post->ID; Or: global $post; $post_id = $post->ID Or you can pass the post ID in a function, much like function my_function($post_id){ // code }

Filter Posts By Tag

here you go, The following returns all posts that belong to category 1 and are tagged “apples” query_posts( ‘cat=1&tag=apples’ ); Add this inside the page before the loop change ‘1’ and ‘apples’ to whatever category and tag you want. If you must use query_posts(), make sure you call wp_reset_query() after you’re done. look here for … Read more