Colliding custom permalink rules

I’m developing a reviews site in WordPress, but am having some difficulties setting up the permalink structure I have in mind.

I created two extra custom post types “reviews” and “products”.
They both have the taxonomy “categories” attached to it. All reviews have the same name as the deepest category attached to it.

Reason for this I want 3 different pages:

  • category page: list view of products within that category + a link to the detailed review for that category
  • review page: a detailed review of all products listed beneath each other.
  • product page: a detailed review of one particular product.

The permalink structure should be like this:

  • category page: /%category%/ (so just the category hierarchy)
  • review page: /%category%/review (I don’t use %postname% because a review will only be in one category hierarchy and I want to show the full category hierarchy in the url)
  • product page: /%category%/%postname%/review

Is this actually technically possible?
I’ve been fiddling a lot yet (with adding permastructs) but only get 1 or 2 to work, but they seem to collide with eachother. Is there a way to bypass this?

Thanks

Go to Source
Author: Laurent

Remove add_action from plugin

I use this plugin. Is for auto expire user on specific date.

I want to add this action add_action(‘edit_user_profile’, array($this, ‘extra_user_profile_fields’)) when is_admin only because i have a conflict with an other plugin. I have try this to source code:

if (is_admin) {
add_action('edit_user_profile', array($this, 'extra_user_profile_fields'))
}

and all work well! But i want to add a function to child theme.

class Expire_User_Admin
{

    var $settings = null;

    public function __construct()
    {
        $this->settings = new Expire_User_Settings();

        // Admin Actions
        add_action('admin_init', array($this, 'expire_user_now'));

        // Profile Fields

        add_action('show_user_profile', array($this, 'extra_user_profile_fields'));
        add_action('edit_user_profile', array($this, 'extra_user_profile_fields'));
        add_action('user_new_form', array($this, 'user_new_form')); 

...
}

So i have try this with no luck. Any thoughts?

add_action('init', 'remove_plugin_action', 9999);
function remove_plugin_action()
{
    $plugin_class = new Expire_User_Admin();    
    remove_action('edit_user_profile', array($plugin_class, 'extra_user_profile_fields'));
    if (is_admin()) {
     add_action('edit_user_profile', array($plugin_class, 'extra_user_profile_fields'));
    }
}

Go to Source
Author: xiamtoula

Need help with .htaccess redirection for WordPress websites

I am changing the domain of my website.

But, I am struggling with the domain redirection. I need to implement this wildcard redirection.

So that I visit.

https://www.oldomain.com/page1

It should go to

https://newdomain.com/page1

Note: The new domain is without www.

Can anyone help me how to implement this?

Go to Source
Author: Nirmal Kumar

ANSWER

A 301 Redirect, or permanent redirect, is recommended when dealing with something similar to this one.

If you just want to hard redirect anything hitting oldomain.com to newdomain.com then a simple Redirect should do like so:

<VirtualHost *:443>
	ServerName oldomain.com
        ServerAlias www.oldomain.com
	Redirect 301 / https://newdomain.com
</VirtualHost>

The above example is also something that you will want to write in a server config like httpd.conf but not in a .htaccess file somewhere on your site directory. It is also clumsy since your old site’s pages – e.g https://www.domain.com/some/page/123 – will redirect only to https://newdomain.com which is the index page of the site.

So the other option would be Rewrite. It is also in case you don’t have root access to the server, and/or other sites that are not yours are sharing it as well. It would look like the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldomain.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301,NC]

The above considers whether the request is written with or without the www subdomain in it. The old links or pages will also get carried over to the new one.