Forums › Forums › Remove CPT base › Not working with the Lore theme
-
AuthorPosts
-
16.04.2020 at 22:10 #279
ViorelMocanu
ParticipantHi,
I activated your plugin and tried all the setup combinations for the theme I need to set up, nothing worked.
https://themeforest.net/item/lore-elegant-knowledge-base-wordpress-theme/16965024?s_rank=2
Using nginx as a server.
I keep seeing 404 for the articles.
Let me know what other details I can provide so you can help, please.
Viorel.
16.04.2020 at 22:10 #281kubiq
KeymasterHi.
Can you replicate your issue on wpsandbox or somewhere where I can access its code?18.04.2020 at 18:26 #282ViorelMocanu
ParticipantNo, sorry. I ended up not using your plugin to solve this, but embedding some code in
functions.php
myself.I can, however, share what eventually worked for me. The custom post type Lore generates is called
lsvr_kba
// ultrahack for routing because WordPress FTW register_post_type( 'lsvr_kba', array( 'rewrite' => false ) ); function custom_post_type_rewrites() { add_rewrite_rule( '[^/]+/attachment/([^/]+)/?$', 'index.php?attachment=$matches[1]', 'bottom'); add_rewrite_rule( '[^/]+/attachment/([^/]+)/trackback/?$', 'index.php?attachment=$matches[1]&tb=1', 'bottom'); add_rewrite_rule( '[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$', 'index.php?attachment=$matches[1]&feed=$matches[2]', 'bottom'); add_rewrite_rule( '[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$', 'index.php?attachment=$matches[1]&feed=$matches[2]', 'bottom'); add_rewrite_rule( '[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$', 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'bottom'); add_rewrite_rule( '[^/]+/attachment/([^/]+)/embed/?$', 'index.php?attachment=$matches[1]&embed=true', 'bottom'); add_rewrite_rule( '([^/]+)/embed/?$', 'index.php?custom_post_type=$matches[1]&embed=true', 'bottom'); add_rewrite_rule( '([^/]+)/trackback/?$', 'index.php?custom_post_type=$matches[1]&tb=1', 'bottom'); add_rewrite_rule( '([^/]+)/page/?([0-9]{1,})/?$', 'index.php?custom_post_type=$matches[1]&paged=$matches[2]', 'bottom'); add_rewrite_rule( '([^/]+)/comment-page-([0-9]{1,})/?$', 'index.php?custom_post_type=$matches[1]&cpage=$matches[2]', 'bottom'); add_rewrite_rule( '([^/]+)(?:/([0-9]+))?/?$', 'index.php?lsvr_kba=$matches[1]', 'bottom'); add_rewrite_rule( '[^/]+/([^/]+)/?$', 'index.php?attachment=$matches[1]', 'bottom'); add_rewrite_rule( '[^/]+/([^/]+)/trackback/?$', 'index.php?attachment=$matches[1]&tb=1', 'bottom'); add_rewrite_rule( '[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$', 'index.php?attachment=$matches[1]&feed=$matches[2]', 'bottom'); add_rewrite_rule( '[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$', 'index.php?attachment=$matches[1]&feed=$matches[2]', 'bottom'); add_rewrite_rule( '[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$', 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'bottom'); add_rewrite_rule( '[^/]+/([^/]+)/embed/?$', 'index.php?attachment=$matches[1]&embed=true', 'bottom'); } add_action( 'init', 'custom_post_type_rewrites' ); function custom_post_type_permalinks( $post_link, $post, $leavename ) { if ( isset( $post->post_type ) && 'lsvr_kba' == $post->post_type ) { $post_link = home_url( $post->post_name ); } return $post_link; } add_filter( 'post_type_link', 'custom_post_type_permalinks', 10, 3 );
I also added a function to prevent duplicates since everything is on root now (categories, posts, everything) but that’s out of scope here.
-
AuthorPosts
- You must be logged in to reply to this topic.