How do I make 301 redirection from `/%post_id%/` to `/%postname%/`?

I’ve written my own solution, sharing it and hoping it will help someone. Add this to your functions.php: <?php add_action(‘parse_request’, ‘redirect_postid_to_postname’); function redirect_postid_to_postname($wp) { // If /%post_id%/ if (is_numeric($wp->request)) { $post_id = $wp->request; $slug = get_post_field( ‘post_name’, $post_id ); // If the post slug === the post number, prevent redirection loops. if ($slug !== $post_id) … Read more

Custom permalinks in WordPress

hi here is the solution if you are asking about custom url. go to pages and edit page ( note that download classic editor first) you can easily create a custom permalink with a classic editor. once you download a classic editor in your WordPress then it is so easy to create custom url for … Read more

Permalink in WordPress loop outputs for each new line

This is happening because the_category() outputs a list of categories, with links. So it’s outputting its own <a> tags, and you cannot put <a> tags inside other <a> tags. It’s not valid HTML. What you’re seeing is the browser’s attempt to produce valid HTML based on invalid markup. HTML is very resilient, and invalid markup … Read more

How to rename ‘Tag Base’ with WPeC 3.8?

Tags are a custom taxonomy called product_tag in WPEC 3.8+, they’re not the same taxonomy as default WordPress tags so that’s why tagbase has no effect. Line 315 in wpsc-core/wpsc-functions.php: register_taxonomy( ‘product_tag’, ‘wpsc-product’, array( ‘hierarchical’ => false, ‘labels’ => $labels, ‘rewrite’ => array( ‘slug’ => “https://wordpress.stackexchange.com/” . sanitize_title_with_dashes( _x( ‘tagged’, ‘slug, part of url’, ‘wpsc’ … Read more

get_permalink() always returns empty

First off, you should use get_posts instead of a raw SQL query. Or at least use $wpdb. <?php $posts = get_posts( array( ‘post_status’ => ‘publish’ ‘numberposts’ => -1 ) ); Then, try passing the entire post object to get_permalink, which saves some database queries. <?php foreach( $posts as $p ) { $link = get_permalink( $p … Read more

How to use different domains for different blogs hosted in the same host in subdomains with .htaccess

You need a vhost for the subdomain that redirects to public_html/sub_domain_folder instead of trying to redirect with .htaccess. You can then do a www redirect in public_html/sub_domain_folder/.htaccess. There should be some option in cpanel when creating the subdomain do specify which folder it directs to if you don’t have direct access to your vhost.

Permalink changes gives me 404 [closed]

Is your rewrite rule in your .htaccess well configured? Can you post it here? Should be configured like this: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Source: Codex page on pretty permalinks

Strange Anchor Tag Behavior (in-page links work, external pages do not) [closed]

Just a tip: the structure of the headings with anchor tags is the following on that site: <h2><a id=”something” name=”something”></a>SOMETHING</h2><p>Description of that thing</p> However, the paragraph of the Corks section also contains the anchor tag of the following Wood section: <a name=”wood”></a>. Then the paragraph is closed and comes the <h2 id=”wood”>WOOD (clean, untreated)</h2> It … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)