Programmatically add a custom url route “/category/index.json” to return a collection of posts in json

Turns out i was able to make it work by hooking into parse_request . add_action(‘parse_request’, ‘serve_index_json’, 0); function serve_index_json($wp) { // Exit early if not the right request if (‘my-category-slug/index.json’ !== $wp->request) { return; } $data = array(); $args = [ ‘posts_per_page’ => -1, ‘category_name’ => ‘my-category-slug’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_status’ => … Read more

Paginate yearly archives for a custom post type

Your regex cannot work: $wp_rewrite->preg_index(3) doesn’t match anything, because you capture only one part in ‘/([0-9]{4})/?$’, not three. Try to add the page parameter: $pagination_base = $GLOBALS[‘wp_rewrite’]->pagination_base; $month_archive = array( $myqueryslug . ‘/([0-9]{4})(‘ . $pagination_base . ‘/(\d+))?/?$’ => ‘index.php?year=” . $wp_rewrite->preg_index(1) . “&post_type=” . $myqueryslug . “&paged=’ . $wp_rewrite->preg_index(3) ); I haven’t tested it, just … Read more

Rewrite and replace url wp-admin/edit.php and wp-admin/post-new.php

The technical answer to this is to put an .htaccess file inside your wp-admin folder with this code: # Remove .php from pages so you can use /wp-admin/edit RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php # Use /wp-admin/addnewpost RewriteRule addnewpost post-new.php The practical answer is that this is completely horrible, involves … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)