Fetching private posts or custom post types via WP-API with basic authentication

I’ve installed WP-API along with Basic Auth. I’m able to fetch cpt posts using curl http://siteurl.com/posts?type={post-type} However, if I change a post to private, it is no longer returned. This is true even when sending the author’s user credentials with either an auth header or simply using curl http://username:[email protected]/posts?type={post-type} Is this by design? Am I … Read more

Change private static final field using Java reflection

I have a class with a private static final field that, unfortunately, I need to change it at run-time. Using reflection I get this error: java.lang.IllegalAccessException: Can not set static final boolean field Is there any way to change the value? Field hack = WarpTransform2D.class.getDeclaredField(“USE_HACK”); hack.setAccessible(true); hack.set(null, true); 14 s 14 Assuming no SecurityManager is … Read more

How to read the value of a private field from a different class in Java?

I have a poorly designed class in a 3rd-party JAR and I need to access one of its private fields. For example, why should I need to choose private field is it necessary? class IWasDesignedPoorly { private Hashtable stuffIWant; } IWasDesignedPoorly obj = …; How can I use reflection to get the value of stuffIWant? … Read more

Let private posts stay in status “private” after edit through “editors”

I’m using some private posts for intern purposes. When an editor changes something on these posts, its status turns to pending “review” and I have to publish it again as a private post. When an editor changes something on a normal page/post – that has already been published for public – the status doesn’t change, … Read more

Set posts of a custom post type to be private by default?

Say I created a custom post type called ‘Private Posts’ ($post_type = itsme_private_posts) and want all posts under the custom post type to be set to ‘Private’ automatically when published i.e. by default. How do I do it? Based on @brasofilo’s answer to a related question on StackOverflow, I tried this: add_filter( ‘wp_insert_post_data’, ‘itsme_cpt_private’, ’99’, … Read more

How can I make it so the Add New Post page has Visibility set to Private by default?

I’m trying to create a plugin that alters the Add New Post page so the Visibility field says “Private” by default: Status: Draft Visibility: **Private** Publish immediately [Publish] …as opposed to what WordPress normally assumes: Status: Draft Visibility: **Public** Publish immediately [Publish] At the moment, I’m using the “wp_insert_post_data” filter, and that is allowing me … Read more

How do I remove unwanted pages like archive, search, etc.?

By default WordPress pushes out a whole array of pages I don’t want or need – archive, author, blog, monthly, recent posts, categories, comments, attachment, taxenomies, search, search results, and probably a few others I’ve missed. Most of the time I’m building regular broshure websites with no need for anything except a few fairly static … Read more