Great plugin – not sure why this is not actively maintained…
There is a widespread issue that can be fixed on the next version, see below:
In wp-permastructure.php:
public function parse_permalinks( $post_link, WP_Post $post, $leavename, $sample = false ) {
with
public function parse_permalinks( $post_link, $post, $leavename, $sample = false ) {
For anyone experiencing conflicts with Yoast SEO.
-Mark
]]>Hi there,
when I activate WP Permastructure the Sitemap for projects shows every URL twice and does not shot the other language. You can see it here:
https://www.crg.world/project-sitemap.xml
Any idea what’s wrong and how I can fix that?
Thank you very much,
Sascha
]]>Hello, Im using your plugin and it works pretty much perfectly, except 1 little problem.
When I try to access my post sitemap – it gives me 500 error.
https://www.coma.lv/sitemap_index.xml
Fatal error: Uncaught TypeError: Argument 2 passed to wp_permastructure::parse_permalinks() must be an instance of WP_Post, instance of stdClass given, called in /home3/coma/public_html/coma.lv/wp-includes/class-wp-hook.php on line 286 and defined in /home3/coma/public_html/coma.lv/wp-content/plugins/wp-permastructure/wp-permastructure.php:244 Stack trace: #0 /home3/coma/public_html/coma.lv/wp-includes/class-wp-hook.php(286): wp_permastructure->parse_permalinks(‘https://www.com…’, Object(stdClass), false) #1 /home3/coma/public_html/coma.lv/wp-includes/plugin.php(203): WP_Hook->apply_filters(‘https://www.com…’, Array) #2 /home3/coma/public_html/coma.lv/wp-includes/link-template.php(240): apply_filters(‘post_link’, ‘https://www.com…’, Object(stdClass), false) #3 /home3/coma/public_html/coma.lv/wp-content/plugins/wordpress-seo/inc/sitemaps/class-post-type-sitemap-provider.php(603): get_permalink(Object(stdClass)) #4 /home3/coma/public_html/coma.lv/wp-content/plugins/wordpress-seo/inc/sitemaps/class-post-type-sitemap-pr in /home3/coma/public_html/coma.lv/wp-content/plugins/wp-permastructure/wp-permastructure.php on line 244
]]>The preview button for custom post types was broken in the metabox and elsewhere. This is the fix that worked for us:]
--- a/wp-content/plugins/wp-permastructure/wp-permastructure.php
+++ b/wp-content/plugins/wp-permastructure/wp-permastructure.php
@@ -334,7 +334,7 @@ class wp_permastructure {
$permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) );
$permalink = user_trailingslashit($permalink, 'single');
} else { // if they're not using the fancy permalink option
- $permalink = home_url('?p=' . $post->ID);
+ $permalink = $post_link ? $post_link : home_url('?p=' . $post->ID);
}
return $permalink;
]]>
when the post permalink is /blog/%postname% the URL is parsed like this (according to debug). Note “name=page” instead of “name=blog”
Request:
blog/page/6
Query String:
page=6&name=page&post_type=post
Matched Rewrite Rule:
blog/([^/]+)(?:/([0-9]+))?/?$
Matched Rewrite Query:
name=page&page=6&post_type=post
I believe it is related to the issue here
https://wpquestions.com/Rewrite_rules_pagination_problem/15041
according to Rewrite Analyzer this rule
blog/([^/]+)?(:/([0-9]+))?/?$ => name: page, page: 3, post_type: post
is firing before
(.?.+?)/page/?([0-9]{1,})/?$ => pagename: blog, paged: 3
thanks for any advice
J
Sometimes the following pops up in my error log:
PHP Catchable fatal error: Argument 2 passed to wp_permastructure::parse_permalinks() must be an instance of WP_Post, instance of stdClass given in .../wp-content/plugins/wp-permastructure/wp-permastructure.php on line 244
Any idea how to find the root cause of this?
]]>Hi,
My theme has portfolio categories. When I used your plugin, under the custom post-type settings there’s “Portfolio items permalink structure”.
So I put /projects/%postname%/ and it works fine,
but when I put: /projects/%category%/%postname%/, the new link url appears as /projects/%category%/category-item which is incorrect and causes a bad request.
I want the category type to show in the permalink, please help me.
]]>As it stands, the %post_name%
rewrite tag in WP Permastructure corresponds only to the slug of the current post. Given a hierarchical custom post type, can there be a way to have this tag (or an entirely new tag, say %hierarchical%
) that corresponds to the entire hierarchical portion of the URL?
Since I’m looking to remove the base slug, my Permastructure could look something like this (this rewrite tag isn’t part of the plugin):
/%hierarchical%
Given a hierarchical custom post type project
, these:
https://example.com/project/a
https://example.com/project/a/b
https://example.com/project/a/b/c
would be rewritten as these:
https://example.com/a
https://example.com/a/b
https://example.com/a/b/c
instead of these, which is the current behavior for the /%post_name%
Permastructure:
https://example.com/a
https://example.com/b
https://example.com/c
Any insights? This plugin is the closest solution I have found that could potentially solve the problem of removing base slugs from hierarchical CPT URLs. All other solutions I’ve tried from online regarding this topic are sub-optimal or cause conflicts with regular page URLs.
]]>Good morning!
After I discovered that this plugin isn’t the plugin I was searching for, I deactivated and deleted the plugin.
After that, when resetting the permalinks in wordpress, everything should be normal.
Unfortunately, when setting the permalinks on ‘post-name’, I receive 404 errors.
From now on I only can use the standard permalink structure (/?p=123).
So my question is: After deleting the plugin, what do I have to do more to reset all settings? Because I think, wp permastructure is permanently changing things in the database.
I hope I hear you soon.
Greets Mark
]]>Did not function with with “/%category%/%postname%” anymore. The %category% will not be resolved.
]]>Hello,
I have on problem with wp-permastructure.
When I create a post, with a defined url, and then I change this URL, the database does not include the change. If I go on the sitemap for example, the sitemap display the old url (not modified) and once I click on this link, WordPress redirect to the new url (301 redirect).
In the database, the plugin does not update ‘post-name’ in ‘wp_posts’ for the ID of the post.
UPDATE ‘db_bame’.’wp_posts’ SET ‘post_name’ = ‘new_name’ WHERE ‘wp_posts’.’ID’=post_id
Can you help me please ?
Is the plugin compatible with Woocommerce? As soon as I switched it on, the Woocommerce pages stop displaying products.
]]>Hi,
I have changed my permalink structure to /%custom_taxonomy_name%/%postname%/ for a custom post type, and it seems to be working, my permalinks are updated. However, the post pages are now blank.
Any idea why?
]]>I am getting 404 errors for /%category%/%postname%/
or /%cust_taxonomy%/%postname%/
I have made sure to flush the rewrite rules. But nothing seems to work.
Are there any specific custom post type register options that need to be used?
register_post_type('landing-page', array(
'label' => 'Landing Pages',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'page',
'hierarchical' => true,
'rewrite' => array(
'permastruct' => '/%category%/%postname%/'),
'query_var' => true,
'supports' => array('editor','title','revisions'),
'taxonomies' => array('campaigns','buyer-seg','stage','ddc-format','category'),
'labels' => array (
'name' => 'my name',
'singular_name' => 'Landing Page',
'menu_name' => 'my name',
'add_new' => 'Add Landing Page',
'add_new_item' => 'Add New Landing Page',
'edit' => 'Edit',
'edit_item' => 'Edit Landing Page',
'new_item' => 'New Landing Page',
'view' => 'View Landing Page',
'view_item' => 'View Landing Page',
'search_items' => 'Search Landing Pages',
'not_found' => 'No Landing Pages Found',
'not_found_in_trash' => 'No Landing Pages Found in Trash',
'parent' => 'Parent Landing Page'
)
)
]]>
Hi all
I could resolve the 404 error ?? that’s good.
but now I can’t make happen to have the custom_cat_name in custom post type url.
I tried to declare into register_taxonomy & register_post_type
intro rewrite : ‘permastruct’ => ‘/mycustomtype/%mycustomtype_category%/%year%/%monthnum%/%day%/%postname%/’
or
‘permastruct’ => ‘/mycustomtype/%category%/%year%/%monthnum%/%day%/%postname%/’
or whatever. I always have the url like :
https://WWW.MYDMAIN/mycustomtype//2015/08/07/titlepost/
having // before year slug.
thanks for helping to resolve this ??
can’t find out
cheers
]]>First off, great plugin! Using it on many sites.
I saw a previous post about this but there was no reply. I’m having trouble getting it to work with a site using WPML. The permalinks end up looking like this:
https://www.example.com/products/category-de/subcategory-de/product-name
Note the “de” for German. Any ideas anyone on a solution? Thanks in advance!
]]>I would like to have an url like /%category%/%postname%.html for my custom post type, but the “.” will be removed everytime I save ??
]]>Created a custom post type, fully tested and working without your plugin. Creating a few more custom post types that would have benefited from this plugin but the order in which the rewrite rules are saved differ from the WordPress way of creating custom post type rewrite permastructure vs using this plugin to create the permastructure.
Tested using rewrite rules inspector plugin.
Custom posts end in 404 error.
]]>Hello,
I’m successfully using your plugin until I need to preview draft or pending custom post : it always gives me a 404 page.
Looking at your code, I saw line 339 :
$permalink = home_url('?p=' . $post->ID);
which is the default permalink given when post status is draft/pending or auto-draft.
The defaut permalink for a custom post type should add post_type=custom_post_type in URL.
So here is the fixed code (line 339) :
$permalink = home_url('?post_type=' . $post_type->name . '&p=' . $post->ID);
When I use this plugin; paging results in a 404. After inspecting the page it seems that an extra / (slash) is added to the page number. When I disable the plugin the paging works again.
]]>Hello,
I m using the version 1.3 of your plugin. I am getting 404 error using %category% when i am using it for default wordpress post and custom post type in same time. But it is working fine if i use it only in of them.
Exemple 1:
default post : /%category%/%postname%/
custom post type : /%category%/%postname%/
ERROR 404
Exemple 2:
default post : /%postname%/
custom post type : /%category%/%postname%/
Working fine !
Exemple 3:
default post : /%category%/%postname%/
custom post type : /%postname%/
Working fine !
Can you help me please !
I need to use the default wordpress category for both.
Thank you
When I updated to WordPress v4.0 it removed all of my custom post type permalinks and replaced them with “/”. In other words, clicking on a custom permalink takes you to the homepage.
I have 2 custom post types: “Business” and “Coupon”. The permalink settings for Business are “/%business_cat%/%postname%/” with has_archive: false / with_front: true
For Coupon, settings are “/coupon/%postname%/” with has_archive: false / with_front: false.
The box is unchecked for “Use custom permalink of custom taxonomy archive”
here is post-types.php
<?php
// Fire this during init
register_post_type('business', array(
'label' => __('Businesses'),
'singular_label' => __('Business'),
'public' => true,
'show_ui' => true,
'capability_type' => 'page',
'hierarchical' => true,
'hierarchical_uri' => true,
'query_var' => 'business',
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', 'revisions', 'page-attributes'),
'taxonomies' => array('business_cat'),
'rewrite' => array('slug' => 'business', 'with_front' => true)
));
register_taxonomy('business_cat', array('business'), array(
'label' => __('Business Categories'),
'singular_label' => __('Business Category'),
'hierarchical' => true,
'hierarchical_uri' => true,
'show_ui' => true,
'query_var' => 'business_cat',
'rewrite' => array('slug' => 'businesses', 'with_front' => true)
// 'with_front' => false
));
register_post_type('coupon', array(
'label' => __('Coupons'),
'singular_label' => __('Coupon'),
'public' => true,
'show_ui' => true,
'capability_type' => 'page',
'hierarchical' => true,
'hierarchical_uri' => true,
'rewrite' => false,
'query_var' => 'coupon',
//'rewrite' => array('slug' => 'coupon', 'with_front' => false),
// 'with_front' => false
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', 'revisions', 'page-attributes')
));
add_action('init', '_business_taxonomy');
function _business_taxonomy() {
global $wp_rewrite;
//$wp_rewrite->add_permastruct('business_cat', '%business_cat%', true, true);
$wp_rewrite->extra_permastructs['business_cat'] =
array('businesses/%business_cat%', false);
$wp_rewrite->add_rewrite_tag("%business_cat%", '.*?/?([^/]+)', "business_cat=");
$wp_rewrite->extra_permastructs['business'] =
array('business/%business_cat%/%business%', false); // business/%business_cat%/%business%
$wp_rewrite->add_rewrite_tag("%business%", '([^/]+)', "business=");
//print_r($wp_rewrite);
}
add_filter('term_link', '_hierarchical_terms_hierarchical_links', 12, 3);
function _hierarchical_terms_hierarchical_links($termlink, $term, $taxonomy) {
global $wp_rewrite;
if ( 'business_cat' != $taxonomy ) // Change 'state' to your required taxonomy
return $termlink;
$termstruct = $wp_rewrite->get_extra_permastruct($taxonomy);
if (empty($termstruct)) // If rewrites are disabled, fall back to the current link
return $termlink;
if ( empty($term->parent) ) // Fall back to the current link for parent terms
return $termlink;
$nicename = $term->slug;
while ( !empty($term->parent) ) {
$term = get_term($term->parent, $taxonomy);
$nicename = $term->slug . '/' . $nicename;
}
$termlink = str_replace("%$taxonomy%", $nicename, $termstruct);
$termlink = home_url( user_trailingslashit($termlink, 'category') );
return $termlink;
}
add_filter('post_link', '_hierarchical_posts_hierarchical_links', 8, 3);
add_filter('post_type_link', '_hierarchical_posts_hierarchical_links', 8, 3);
function _hierarchical_posts_hierarchical_links($permalink, $post, $leavename) {
global $wp_rewrite;
if ($post->post_type != 'business')
return $permalink;
$postlink = $wp_rewrite->get_extra_permastruct('business');
$post_name = $post->post_name;
if (!empty($post->post_parent)) {
$parent_posts = get_post($post->post_parent);
$post_name = $parent_posts->post_name . '/' . $post_name;
}
$postlink = str_replace("%business%", $post_name, $postlink);
$terms = get_the_terms($post->ID, 'business_cat');
if (!empty($terms)) {
foreach ($terms as $term_id => $term) {
$termname = $term->slug . '/' . $termname;
}
$termname = substr($termname, 0, -1); // remove the trailing slash
}
$postlink = str_replace("%business_cat%", $termname, $postlink);
$postlink = str_replace("//", '/', $postlink);
return home_url(user_trailingslashit($postlink, 'single'));
}
//add_action('init', 'flush_rewrite_rules');
?>
]]>
Just tried it — and this plugin seems to be great for providing a permalink structure for custom taxonomies and post types. Thanks!
Unfortunately, I did also get the following PHP Strict notices from Query Monitor:
Only variables should be assigned by reference
wp-content/plugins/wp-permastructure/wp-permastructure.php:256
Only variables should be assigned by reference
wp-content/plugins/wp-permastructure/wp-permastructure.php:351
]]>
This works:
/advert/%types%/%postname%/
This does not, and returns the 404 error page:
/%types%/%postname%/
Any ideas to what may be wrong?
]]>I installed this plugin and tried to change the permalink structure of a custom post type.
/%injury_category%/%postname%/
is the code i used in permalink settings. But I am getting 404 error. ‘injury_category’ is the custom taxonomy name.
function injury_post_type() {
$labels = array(
'name' => __('Injury','reo_theme'),
'singular_name' => __('Injury','reo_theme'),
'add_new' => __('Add Injury','reo_theme'),
'add_new_item' => __('Add New Injury','reo_theme'),
'edit_item' => __('Edit Injury','reo_theme'),
'new_item' => __('New Injury','reo_theme'),
'view_item' => __('Preview Injury','reo_theme'),
'not_found' => __('No Injurys Found','reo_theme'),
'not_found_in_trash' => __('No Injurys Found In Trash','reo_theme'),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 100,
'supports' => array(
'title',
'editor',
'thumbnail'
)
);
register_post_type(__( 'injury','reo_theme'), $args);
}
//END: injury_post_type
// injury_messages
function injury_messages($messages)
{
$messages[__( 'injury' )] =
array(
0 => '',
1 => sprintf(__('Injury Updated.','reo_theme'), esc_url(get_permalink($post_ID))),
2 => __('Custom Field Updated.','reo_theme'),
3 => __('Custom Field Deleted.','reo_theme'),
4 => __('Injury Updated.','reo_theme'),
5 => isset($_GET['revision']) ? sprintf( __('Injury Restored To Revision From %s','reo_theme'), wp_post_revision_title((int)$_GET['revision'], false)) : false,
6 => sprintf(__('Injury Published.','reo_theme'), esc_url(get_permalink($post_ID))),
7 => __('Injury Saved.','reo_theme'),
8 => sprintf(__('Injury Submitted.','reo_theme'), esc_url( add_query_arg('preview', 'true', get_permalink($post_ID)))),
9 => sprintf(__('Injury Scheduled For: <strong>%1$s</strong>.','reo_theme'), date_i18n( __( 'M j, Y @ G:i' ), strtotime($post->post_date)), esc_url(get_permalink($post_ID))),
10 => sprintf(__('Injury Draft Updated.','reo_theme'), esc_url( add_query_arg('preview', 'true', get_permalink($post_ID)))),
);
return $messages;
} // END: injury_messages
//Get the thumbnail
function injury_thumbnail($post_ID) {
$injury_thumbnail_id = get_post_thumbnail_id($post_ID);
if ($injury_thumbnail_id) {
$injury_thumbnail_img = wp_get_attachment_image_src($injury_thumbnail_id, 'featured_preview');
return $injury_thumbnail_img[0];
}
}
//Modify admin columns
function injury_edit_columns($columns){
$columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => __('Injury title','reo_theme'),
"thumb" => __('Preview image','reo_theme'),
);
return $columns;
}
//Content for admin columns
function injury_custom_columns($column){
global $post;
switch ($column)
{
case "thumb":
$injury_thumb = injury_thumbnail($post_ID);
if ($injury_thumb) {
echo '<img src="' . $injury_thumb . '" width="55" />';
}
break;
}
}
add_action( 'init', 'injury_post_type' );
add_action('admin_menu', 'injury_settings_menu');
add_filter( 'injury_updated_messages', 'injury_messages' );
add_filter('manage_reo_injury_posts_columns', 'injury_edit_columns');
add_action('manage_reo_injury_posts_custom_column', 'injury_custom_columns', 10, 2);
add_action( 'init', 'create_discog_taxonomies', 0 );
function create_discog_taxonomies()
{
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'Injury Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Injury Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Injury Categories' ),
'popular_items' => __( 'Popular Injury Categories' ),
'all_items' => __( 'All Injury Categories' ),
'parent_item' => __( 'Parent Injury Categories' ),
'parent_item_colon' => __( 'Parent Injury Category:' ),
'edit_item' => __( 'Edit Injury Category' ),
'update_item' => __( 'Update Injury Category' ),
'add_new_item' => __( 'Add New Injury Category' ),
'new_item_name' => __( 'New Injury Category Name' ),
);
register_taxonomy('injury_category',array('injury'), array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'injury-category' ),
));
}
This is the custom post type register code. Please help me to resolve this problem
Thanks
]]>Just installed the plugin and although it does what it says it does, I am getting 2 Strict Standards Notices:
Strict Standards: Only variables should be assigned by reference in /path/wp-content/plugins/wp-permastructure/wp-permastructure.php on line 256
Is there any way to solve that?
Thanks,
Piet
Wondering if anyone else has ran into this issue and if there was fix. If I only add one permalink structure it works perfectly. If I add two peramlink structures the last one works but not the first one.
Any help would be greatly appreciated.
https://www.dropbox.com/s/sjor73k0ufg39cf/Screenshot%202014-06-16%2012.15.51.png
It is working quite well until I noticed that /something/%category%/%postname% isn’t quite valid sometimes.
When I type in any text on the %category% in the browser, it accepts anything. Not returning 404…
]]>First of all thanks for a great plugin.
I had not been able to achieve a permalink structure
/taxonomyname/cptslug
Using this permalink I couldn’t get the above permalink working but
/taxonomyname/cptslug/cpt_id worked fine so i sticked with this permalink.
Now I’ve come across another big problem that the url’s not been resolved for the second language
https://domain/taxonomyname_lang1/cptslug_lang1/cpt_id_lang_1 ( main language)
but instead of
https://domain/lang2/taxonomyname_lang2/cptslug_lang2/cpt_id_lang2 ( main language)
It is sending to url
https://domain/taxonomyname_lang2/cptslug_lang2/cpt_id_lang2
Please Help
]]>Hi Guys,
Thanks for this plugin, it’s got me the furthest to getting where we want to be.
We have a custom post type and taxonomies set up. The only thing left is we want the hierachy of taxonomies in the url and not just the top level taxonomy.
Eg, we have a custom post type tagged to these taxonomies:
Europe
United Kingdom
Wales
But in the URL I only get europe/post-name
The end goal is to have:
europe/united-kingdom/wales/post-name
Any help would be greatly appreciated!
Thanks
https://www.ads-software.com/extend/plugins/wp-permastructure/
]]>