Tag Info

New answers tagged

1

You can use rewrite arg in register_post_type. You can have custom post type name different then rewrite slug. For example here is the sample code with custom post type project and it shows pages with http://shaowtriger.com/brands/naim/ Notice rewrite in $args add_action( 'init', 'codex_brand_init' ); function codex_brand_init() { $labels = array( ...


0

You have to make your rewrite rules account for the paged parameter, because otherwise they won't. It would look somewhat like shown below. function test_add_rewrite_rules() { add_rewrite_rule( 'businesses/(eat|stay|play)/(.+)/page/([0-9]+)/?$', ...


0

Only one thing I can see to solve this problem is to use redirection by .htaccess. But my question is, why don't you manage to redirect old URLs to the new version, without the /blog ? Because I guess, your concern is most about SEO no ? redirect 301 /blog/ http://www.yourdomain.com/


1

I found a solution here: Custom post types, taxonomies, and permalinks TheDeadMedic's solution worked like a charm. function filter_post_type_link($link, $post) { if ($post->post_type != 'project') return $link; if ($cats = get_the_terms($post->ID, 'project_categories')) $link = str_replace('%project_categories%', array_pop($cats)->slug, ...


0

To add query strings to post permalink you should use the post_link filter in combination with the add_query_arg function. add_filter( 'post_link', 'cyb_append_query_string', 10, 3 ); function cyb_append_query_string( $url, $post, $leavename ) { //Change for the post type you want if ( $post->post_type == 'home' ) { $url = add_query_arg( ...


0

Note to curators/admin: I wanted to leave a comment but I didn't have enough reputation. I know I am not formally providing an answer, but attempting to help the person asking the question along. Are you using any membership plugins? Can you give us a little more information on the overall site map and functionality? We are seeing a very narrow field of a ...


0

I solved this problem using wp_get_object_terms, probably not the cleanest way but it does what I wanted. For those of you having the same problem, this is how my final product looks: function custom_permalink( $post_link, $id = 0, $leavename ) { global $wp_rewrite; $post = &get_post( $id ); if ( is_wp_error( $post ) || $post->post_type ...


0

Have you tried adding the third parameter to that call? add_rewrite_tag( '%make%', '([^/]+)', 'make=' );


0

This rewrite rule will surely work. Add this code to your .htaccess file. RewriteEngine On RewriteRule ^uni/([^/]*)$ /gallery/?university=$1 [L]


0

I needed to reset the permalink setting to Default, then change it back to the custom structure I was using. This apparently resets it.


0

Ok. Then you can use template_redirect hook and wp_is_mobile() conditional tag. wp_is_mobile() will work on device only. If you resize the window then it will not work. Now you can try this kind of code in your functions.php file add_action('template_redirect', 'redirecting_to_mobile_site'); function redirecting_to_mobile_site(){ if( wp_is_mobile() ){ ...


2

I'm not sure but I think that you just need to add two query vars, "group" and "value", not two rewrite tags. Can you try this: add_filter('query_vars', 'cyb_add_query_vars'); function cyb_add_query_vars( $vars) { $vars[] = "group"; // name of the var as seen in the query string and URL $vars[] = "value"; return $vars; } ...


2

When you register the post type, set the argument 'has_archive' to a string, in your case plugins. The doc block for register_post_type() says: @type bool|string $has_archive Whether there should be post type archives, or if a string, the archive slug to use. Will generate the proper rewrite rules if $rewrite is enabled. Default false. Minified ...


0

I wrote an article a while ago on how to do this using Bit.ly and a custom url. http://craigmdennis.com/articles/set-up-a-custom-short-url-with-wordpress Buy a short URL Sign up for bit.ly Add an A Record to point to bit.ly and verify it Download & install bit.ly Service WordPress plugin Use <?php echo wp_get_shortlink(); ?> in your theme As ...


0

Here's a possibly simple solution, using an ancillary table, and user-defined short slugs: create a post_meta "short_slug" when creating a post, the link-name from your example on save_post, if (meta_key='short_slug' and is_a_valid(meta_value)) wpdb->insert into short_slugs_table slug,permalink , your index.php on your mgscr.com could then ...



Top 50 recent answers are included