permalinks

Removing date from url using .htaccess

你离开我真会死。 提交于 2019-12-05 03:39:04
问题 I recently changed the permalink format of my blog so the date is removed: http://site.com/blog/2011/01/post-name is now http://site.com/blog/post-name The problem is the url with date is not redirected to new url. I tried some regular expressions in .htaccess but still get 404. Any ideas? 回答1: The solution was RedirectMatch 301 /blog/([0-9]+)/([0-9]+)/(.*)$ /blog/$3 http://www.catswhocode.com/blog/10-awesome-htaccess-hacks-for-wordpress 回答2: Use this rewrite: RewriteRule blog/\d{4}/\d{2}/(.*

Have a WordPress page with same title as custom post type “front” slug

不想你离开。 提交于 2019-12-05 00:46:43
I have a custom post type djs and a custom taxonomy city with two terms: boston and nyc . So a DJ can either be tagged as Boston or NYC. DJ profiles (a single djs post) are located at /nyc-wedding-dj/joe-shmoe/ , for example, or for a Boston DJ, /boston-wedding-dj/jane-doe/ . In other words, the rewrite slug for that custom post type is set as %city%-wedding-dj . I have two regular pages called /boston-wedding-djs/ and /nyc-wedding-djs/ (note the plural DJs with an s ) where I use a custom page template to loop through the DJs from the corresponding city and display a list of links to DJ

How to Set POST permalink/slug in wordpress using wp_insert_post

牧云@^-^@ 提交于 2019-12-04 19:19:42
问题 I m writing simple script using wp_insert_post() to post article in blog. but one problem here, I want to make Title and slug of an URL different. How to achieve this? for example: Title: How to make your diet success Slug: 7-ways-to-make-succes-Diet 回答1: post_title sets the title, and post_name sets the slug. So: // Create post object $my_post = array( 'post_title' => 'How to make your diet success', 'post_name' => '7-ways-to-make-succes-Diet', 'post_content' => 'my content', 'post_status' =

WordPress Permalink 404 Error after Subdomain to Root Migration

耗尽温柔 提交于 2019-12-04 19:18:44
I have a WordPress installation at Subdomain. I wish to have the website display the blog at http://www.website.com The WordPress folder is located at http://www.website.com/wordpress/ The migration is complete but the pretty permalinks do not work. For the default permalink structure, its fine but for /%postname%/ it displays 404 Errors. This is the .htaccess code WP has generated in the root # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php

How to remove one specific category (uncategorized) from post permalinks

允我心安 提交于 2019-12-04 19:18:09
I have several posts on my wordpress site. Most of them belong to a specific category, but some don't. For all the posts that belong to a category I want to have the following permalink structure: /%category%/%postname%/ All the other default posts belong "automatically" to the uncategorized category. Their URL structure will look like this /uncategorized/%postname%/ I want to change permalinks to the following: /%postname%/ Is there a way to make an exception for the permalinks that belong to the uncategorized category? Thanks in advance! The solution bellow worked for me. In function.php,

Get the grouped product link from one of it's childs in woocommerce 3

最后都变了- 提交于 2019-12-04 18:47:00
With woocommerce 2.3 there was post_parent for single products what was the part of grouped product. So it was possible to link them by: function parent_permalink_button() { global $post; if( $post->post_parent != 0 ){ $permalink = get_permalink($post->post_parent); echo '<a class="button" href="'.$permalink.'">Link to Parent</a>'; } } with woocommerce 3.0.0 update situation changed. Actually it is opposite now. Grouped product has its _children. How can I create the link from single product to its grouped? It can be a part of more grouped product so there can be multiple links (but it is not

Random permalink key in wordpress

末鹿安然 提交于 2019-12-04 17:05:03
I want to have a custom permalink for each new post in WordPress like: http://mysite.com/x5Kvy6 (like bit.ly). I tried this little script, but it adds only 5-digit numbers to the post title in the permalink. function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) { if($slug!=""){ $random=rand(11111,99999); //I needed 5 digit random $slug .= "-" . $random; } return $slug; } How can I make a random key instead of the post title? I have not researched URL shorteners or redirection methods. Any idea is welcome! function wp_unique_post_slug($col,$table='wp_posts'){

How to create permalink in htaccess

喜夏-厌秋 提交于 2019-12-04 16:22:24
I want to redirect a link to another with .htaccess file in Linux host. Can you help me? from: http://example.com/examp to: http://example.com/examp.php And another one for my other site from: http://example.com/examp to: http://example.com/user.php?u=examp You will need mod_rewrite enabled for this. Start with placing these lines into .htaccess: RewriteEngine On RewriteBase / TBH I'm not 100% sure what do you mean exactly by permalink and how do you want to redirect, so I will provide 2 variants for each URL: rewrite (internal redirect) and redirect (301 Permanent Redirect). 1. This will

First image only from photoset on indexpage, then all on permalinkpage

微笑、不失礼 提交于 2019-12-04 12:37:29
Hello - I've been playing around with tumblr photosets and currently i'm using a masonry based theme. With the photosets, i wish to just show the first image of the photoset on the index page but on the permalink page i wish for all the images of the photoset to be shown. Thanks graygilmore You just need to adjust how you display it depending on if you're on the Index or Permalink. On the index, you'll loop through all of the photos and hide all of them except the first one via CSS. First, you'll add in a CSS hook so you know you're on the Index page (should do this anyways): <body class="

Install WordPress in its own directory but permalink fails

心不动则不痛 提交于 2019-12-04 10:01:52
I installed WordPress on EC2, located in /var/www/html/wordpress . I followed the WordPress guide to copy index.php and .htaccess to root which is /var/www/html , and modified index.php and setting in admin panel. It works pretty well if I stick to only default link, such as: http://www.cubcanfly.com/?p=5 , however other permalink options fails, actually all of the permalink options. My .htaccess is # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index