New answers tagged url-rewriting
0
See my answer here: http://wordpress.stackexchange.com/a/100486/12324.
The issue you're facing is that permastructs are adding multiple custom post types to the URL, which is confusing WordPress. You'll need to add your rewrite rules using add_rewrite_rule().
0
It sounds like you're very close here and your only remaining issue is that your permalinks for genres and movies collide.
'movies' CPT permalink
/genres/%custom field meta box value%/%movie%/
'genres' CPT permalink
/genres/%genre%/
The issue here is using the add_permastruct. When it creates the rules for movies, they look something like this:
...
0
You could alter the query directly in your template or use the pre_get_posts action.
Inside archive template:
$taxonomies_to_match = array('the_room','the_system','the_style');
if(is_tax($taxonomies_to_match)) {
global $wp_query;
query_posts(array_merge($wp_query->query_vars,array('post_type' => 'the_case_study'));
}
Action Hook Method:
...
0
Step 2. However, when I submit an un-matching password, the form is redisplayed and URL is now http://example.com/wp-login.php?action=resetpass&key=xyz&login=zyx. Notice, that action has changed.
When I attempt this with an invalid key I get redirected to http://example.com/wp-login.php?action=lostpassword&error=invalidkey.
Anyway, the ...
1
You could override your query with pre_get_posts in functions.php:
function add_all_fruits_to_category($query) {
$catnames = $query->get('category_name');
if ($catnames == 'fruits') {
$query->set('category_name', $catnames . ',bananas,apples,pears');
}
}
add_action('pre_get_posts', 'add_all_fruits_to_category');
2
Use get_template_directory_uri():
$url = get_template_directory_uri() . '/images/myimage.jpg';
This function will always return the correct path to your theme.
If you want to hide/shorten that URL, you could use an endpoint, maybe img. The downside is, you load the complete WordPress for each image request.
Or use mod_rewrite:
RewriteRule ...
1
I think you're taking the wrong approach in terms of data structure. You should create a custom taxonomy called Genres, and bind your movies CPT to the Genres custom taxonomy, and then select which Genres the movie belongs to.
To address questions about your existing code. single-XXX.php template is used to display content from the CPT called XXX. So in ...
1
I would say you need to add the following rewrite rule in your foreach loop:
add_rewrite_rule('^'.$pt_slug.'/category/(.+?)/page/?([0-9]{1,})/?','index.php?post_type='.$post_type.'&category_name=$matches[1]&paged=$matches[2]','top');
0
You have the rewrite argument defined inside the $labels array, move it out to the $args array:
$args = array(
'labels' => $labels,
'hierarchical' => true,
'rewrite' => array('slug' => 'projects', 'with_front' => true)
);
1
one way you could do this with an internal WordPress rewrite, which would then set a query var you could check when enqueueing your javascript, and pass that data via localize script.
so first, rewrite rule to intercept requests to gallery/ with something appended, load the page named gallery, and set the query var gallery_id to whatever was in the URL. ...
0
You can use the add_query_arg funtion:
add_query_arg('filter_id', 1);
add_query_arg('filter_id', 2);
Now the URLs read as follows:
http://mysite/tips/cat?filter_id=1
http:// mysite/tips/dog?filter_id=2
You can get the arguments' values as follows:
$id = get_query_var('id');
$filter_id = get_query_var('filter_id');
Here is more infomation about ...
1
To change all author URLs one would normally change the author base, however, since you want multiple author bases, we'll have to do things a bit differently.
There are two parts to this - The first part is getting WordPress to recognize incoming requests for your custom author pages and route them properly. To do this we'll add two new rewrite rules that ...
2
Redirects are GET requests usually, and the browser doesn’t send the POST data for those. That’s not something WordPress can change.
You could create a session, or – better – process the POST data first, then redirect. In your plugin, you could do:
add_action( 'plugins_loaded', 'process_post_data', 0 );
function process_post_data()
{
// Read raw POST ...
0
You would need to create a custom rewrite rule that maps not just the post slug but also the cid value, see this article:
http://www.prodeveloper.org/create-your-own-rewrite-rules-in-wordpress.html
And the relevant Codex documentation:
http://codex.wordpress.org/Rewrite_API
http://codex.wordpress.org/Rewrite_API/add_rewrite_rule
I'm assuming you don't ...
1
The parameter you are using is wrong. There is no set_front parameter when you register a Custom Post Type. The appropriate parameter is with_front.
'with_front' => bool Should the permastruct be prepended with the
front base. (example: if your permalink structure is /blog/, then your
links will be: false->/news/, true->/blog/news/). Defaults to true
...
0
Is your Blog page the one that's set in the back end at Settings > Reading > Posts page? If so, try checking for that in your first function:
/* Add .htm extension to Page URL Links */
add_action('init', 'htm_page_permalink', -1);
function htm_page_permalink() {
global $post;
if( get_option( 'page_for_posts' ) == $post->ID ) {
// ...
0
I am not entirely sure what you are asking but that ?p= pattern is a raw query string. That is, that is what you get without pretty permalinks at all.
Go to Settings->Permalinks in wp-admin and select the default permalinks. Save and you are done. You don't need any other function. If that doesn't solve it you need to rewrite your question so that it is ...
Top 50 recent answers are included
