I've been trying to find a solution for days now and I am absolutely stumped.

I am putting together a website to list my domain portfolio for sale and I'm using a plugin I purchased to lists the domains. The author of the plugin is nowhere to be found and I only have a basic understanding of PHP.

The plugin lists each domain name as an individual post, but it uses a custom post type which is displaying the post page url as optibrands.com/?mdlp_my_domain_list=znvr-com where znvr.com is the domain for sale and title of the post.

What I want to do is clean up the url by removing /?mdlp_my_domain_list= and having it displayed as optibrands.com/znvr-com or optibrands.com/domain/znvr-com if the former isn't possible.

I tried rewriting the htaccess tons of different ways, but nothing has worked. The closest I've come is adding:

`RewriteEngine On RewriteCond %{THE_REQUEST} \ /+(index.php)?\?mdlp_my_domain_list=([^&\ ]+) RewriteRule ^ /%2? [L,R]

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)$ /?mdlp_my_domain_list=$1 [L,QSA]`

This rewrites the urls how I would like, but it creates a redirect loop error.

I have also tried tweaking the plugin's functions PHP, but I'm not quite sure I know what I need to be editing.

These are the pieces of code I think need to be rewritten:

public function filterRewriteRules( $wp_rewrite ) {

                        $base = trailingslashit( $this->rewriteSlug );
                        $baseSingle = trailingslashit( $this->rewriteSlugSingular );
                        $baseTax = trailingslashit( $this->taxRewriteSlug );
                        $baseTax = "(.*)" . $baseTax;

                        $newRules[$base . 'page/(\d+)'] = 'index.php?post_type=' . self::POSTTYPE;
                        $newRules[$baseTax . '([^/]+)/?$'] = 'index.php?post_type= ' . self::POSTTYPE;

                        $wp_rewrite->rules = $newRules + $wp_rewrite->rules;

and/or

public function initialize() {
                                $this->pluginName = __( 'My Domain List', $this->pluginDomain );       
                                $this->rewriteSlugSingular = 'my-domain-list-pro-single';      
                                $this->rewriteSlug =    'mdlp_my_domain_list';                         
                                $this->taxRewriteSlug = $this->rewriteSlug . '/' . __( 'mdlp_categories', $this->pluginDomain );

and/or

public function create_post_type() {
                    $this->get_post_type_labels();
                    register_post_type(self::POSTTYPE, $this->postTypeArgs);                       
                    register_taxonomy( self::TAXONOMY, self::POSTTYPE, array(
                            'hierarchical' => true,
                            'update_count_callback' => '',
                            'query_var'=>true,
                            'rewrite' => false,
                            //'rewrite' => array('slug'=> $this->taxRewriteSlug),
                            'public' => true,
                            'show_ui' => true,
                            'has_archive' => true,
                            'labels' => $this->taxonomyLabels

Edit: Here is the entire contents of the PHP file

If anyone has any idea what I can do to fix this I will be forever grateful, because I've just about given up hope!

  • Can you please edit the question to include the portion of code that registers the custom post type in the plugin? – Courtney Ivey Oct 28 '14 at 18:22
  • 1
    what exactly does this plugin do for you that simply registering your own custom post type won't give you? it seems that rather than try to fix the plugin, you can just register a post type with rewrite set to true and be done with it. – Milo Oct 28 '14 at 18:23
  • @CourtneyIvey I added the php to the question. – Cody Hendrix Oct 28 '14 at 18:32
  • @Milo It allows me to bulk upload thousands of domain names + attributes from a csv file. Then it also lists them in a sortable/filterable table and uses an api to autofill certain domain attributes. Here is the plugin page to get an idea If there is an easier way to do all this please let me know, cause my lack of PHP knowledge is why I bought the plugin in the first place! – Cody Hendrix Oct 28 '14 at 18:37

Based on your pastebin of the plugin code, the issue seems to be in the registration of the custom post type. The issue is on line 25. "Rewrite" should be set to true.

<?php
                private $postTypeArgs = array(
                    'public' => true,  
                    'rewrite'=> false,                
                    'singular_label' => 'mydomainlist',
                    'publicly_queryable' => true,
                    'show_ui' => true,
                    'show_in_menu' => true,
                    'query_var' => true,                   
                    'capability_type' => 'post',
                    'has_archive' => true,
                    'hierarchical' => false,
                    'menu_position' => 5,      
                    'supports' => array('title','editor','author','thumbnail','excerpt','comments', 'custom-fields', 'revisions')
                );    

You should use: 'rewrite'=> true

  • Edited it to true and now the post page gives a 404. Is there anything else that needs to be added to it? – Cody Hendrix Oct 28 '14 at 19:03
  • Be sure to visit the "Settings" > "Permalinks" page in the dashboard and save the settings to update the rewrite rules. – Courtney Ivey Oct 28 '14 at 19:12

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.