WP JSON list all permalinks

Is it possible to do this with a rest query + filters? eg. http://wpsite.com/wp-json/wp/v2/posts?filter[only-permalinks] Yes, since 4.9.8 (see #43874) it’s possible to render only fields needed with the _fields parameter. Examples Render only the permalinks: https://example.com/wp-json/wp/v2/posts?_fields=link [ { link: “https://example.com/foo/” }, { link: “https://example.com/bar/” }, ] Render only the post IDs and permalinks: https://example.com/wp-json/wp/v2/posts?_fields=id,link [ … Read more

mod_rewrite enabled but Permalinks show index.php

The output of $_SERVER[‘SERVER_SOFTWARE’] is WebServerX That looks like your problem – check out this line in wp-includes/vars.php: /** * Whether the server software is Apache or something else * @global bool $is_apache */ $is_apache = (strpos($_SERVER[‘SERVER_SOFTWARE’], ‘Apache’) !== false || strpos($_SERVER[‘SERVER_SOFTWARE’], ‘LiteSpeed’) !== false); I think you’ll need to override this variable manually, either … Read more

Is there a way to use regular categories with custom post types?

No problem, the categories and tags are also registered as taxonomies that you can pass to the taxonomies argument when you call register_post_type(). Categories are category and tags are post_tag. You can also do this later with register_taxonomy_for_object_type(): add_action( ‘init’, ‘wpse6098_init’, 100 ); // 100 so the post type has been registered function wpse6098_init() { … Read more

Custom Post Type: Get most recent permalink

Here is a simple function that will return the Permalink of the last painting post: function Get_most_recent_permalink(){ global $post; $tmp_post = $post; $args = array( ‘numberposts’ => 1, ‘offset’ => 0, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘Painting’, ‘post_status’ => ‘publish’ ); $myposts = get_posts( $args ); $permalink = get_permalink($myposts[0]->ID); $post = $tmp_post; … Read more

Pretty URL with add_query_var

add_rewrite_endpoint( ‘changelog’, EP_ROOT ); Will add the endpoint, changelog, which you can then check on template_redirect hook. On match the query variables ( $wp_query->query ) array should contain key changelog containing whatever comes after the / in value. So for URL example.com/product1/changelog/5 you would have a query variable named changelog with the value 5. If … Read more

Different permalink for posts and authors

I would just change the author_base on the global $wp_rewrite object. Also add a field to the Permalink options page, so you can change it at will. To start: a class to wrap everything up. <?php class Custom_Author_Base { const SETTING = ‘author_base’; private static $ins = null; public static function instance() { is_null(self::$ins) && … Read more

What is the best practice to check for pretty permalinks?

The Using Permalinks page on WordPress.org tells you how to check for the permalink structure: if ( get_option(‘permalink_structure’) ) { echo ‘permalinks enabled’; } The result will be an empty string if permalinks are default, otherwise you will get the permalink pattern though you should not have to worry much about the permalink details if … Read more