Using %postname% tag with a Custom Permastruct creates 400 Bad Request Errors from the server

Okay, I feel stupid. I needed to translate %postname%. I thought it did so automatically since the admin page looked like it had but apparently if you do use custom permastructs, you have to translate even the default tags. My solution: add this to my post_type_link filter: $post = get_post($post_id); $permalink = str_replace(‘%postname%’, $post->post_name, $permalink); … Read more

Plugin to Consume a Web Service

The link you’ve giving is for the function add_rewrite_tag() not WP_Rewrite::add_rewrite_tag()Codex. The later documentation is a bit misleading because it links the other global function (which has two arguments) as if it was the same. But the function you’re referring to has three arguments. I updated the codex a bit to make this more clear.

Change page /2 to /transcript with a Rewrite

The rewrite API won’t redirect – it just “maps” URL structures to query strings – you’ll need to do this yourself. First things first, fix that rewrite rule: ‘episode/([^/]+)/transcript’; // Matches anything that follows transcript, not what we want! ‘episode/([^/]+)/transcript/?$’; // Matches only “episode/name/transcript”, optionally with a trailing slash Now bring in a helper function: … Read more

How to achieve this permalink -> category-name/custom-post-type-name/post-name

You have to filter ‘post_type_link’ to create the appropriate permalink. See this answer for a similar example. The following code works: add_action( ‘init’, array ( ‘WPSE_63343’, ‘init’ ) ); class WPSE_63343 { protected $post_type=”video”; public static function init() { new self; } public function __construct() { $args = array ( ‘public’ => TRUE, ‘rewrite’ => … Read more

Add rewrite endpoint to author page + pagination

Your code should works. The line: include (get_template_directory_uri() . ‘/articles.php’); Needs to have allow_url_include=1 in the server configration because you are trying to include a file via http. Can you check this? You must know also that template_redirect should be use for a real redirect, a include() may have undesired effects here. I think what … Read more

Custom taxonomies, with custom rewrites/slug, AND loading a taxonomy archive template from a plugin

Background & Core Functionality Why a Taxonomy Path Slug Alone Produces a 404 However this slug doesnt work. mysite.com/wiki/help-topics throws a 404. WordPress does not provide a mechanism for “an archive of taxonomy terms” out of the box – that is, neither the template hierarchy nor the WP_Query/WP_Tax_Query logic support a direct display of terms … Read more

Need help with rewrite_rules_array

Try this: function when_rewrite_rules( $wp_rewrite ) { $new_rules = array(); $new_rules[‘category/tasks/(\d*)$’] = ‘index.php?when=$matches[1]’; $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_filter(‘generate_rewrite_rules’,’when_rewrite_rules’);

rewrite_rule() not preserving the query string

If faculty is a child page of meetings, the rule should be: add_rewrite_rule( ‘meetings/faculty/([^/]+)/?$’, ‘index.php?pagename=meetings/faculty&hash=$matches[1]’, ‘top’ ); pagename=meetings/faculty instead of p=1598 EDIT- or alternately: add_rewrite_rule( ‘meetings/faculty/([^/]+)/?$’, ‘index.php?page_id=1598&hash=$matches[1]’, ‘top’ ); page_id=1598 instead of p=1598

Taxonomy archives based on Custom Post Type

Here is a complete example made possible using add_rewrite_rule(). The basic setup for this example is documented first, then we’ll get to the real part of the solution using add_rewrite_rule(). Taxonomy and Post Type registration Register the genre taxonomy and the book, movie, and game post types (note that the singular version of each of … Read more

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