Forum Replies Created

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter McSalty

    (@mcsalty)

    I also found this guide where the guy is doing something similar – installing wordpress blogs as subdomains on a main domain running on django:
    http://tech.velmont.net/howto-use-subdomain-wordpress-multisite-3-x-3-0-and-3-1-without-dashboard-site/

    But to me it seems more complicated and prone to breaking than simply redirecting the subdomains manually using the domain mapping plugin and CNAME records (since I only need to setup a finite number of subdomains, and then I’m finished with my setup). But someone correct me if I’m wrong.

    Thread Starter McSalty

    (@mcsalty)

    Which part do you think will cause a problem? If the plugin can handle subdomain mapping, then I would think it wouldn’t be too different from a normal multi-site install with multiple external domain names. Just in this case those subdomains are all “children” of a single external domain name.

    Anyway, I suppose I’ll just try it out and see how it goes. I appreciate your input, and if anyone else has any thoughts I’d love to hear them.

    Thread Starter McSalty

    (@mcsalty)

    No, maindomain.com serves a different purpose and cannot be converted to a wordpress site.

    Thread Starter McSalty

    (@mcsalty)

    Thanks for the response. The problem is, maindomain.com is not a wordpress site. However, the blogs are fixed in number and there’s no need to allow users to create new blogs. Thus I was thinking of just manually mapping all of the subdomains so it “looks like” they’re hosted one subdomain.maindomain.com even if wordpress is actually installed in a different location.

    That makes sense. Thanks a lot for the response!

    Any reason that “Unique IPs” would be consistently higher than “Visits” under the “Visitors” tab? For example, slimstat reports that yesterday I had 31 visits from 78 IPs. How does that make sense?

    anthonyCCL,

    My code had nothing to do with the plugin — it was a functions.php patch to make custom taxonomies work in normal post permalinks. (Whereas the plugin sets permalinks for custom post types).

    In the latest version of the plugin, custom taxonomies work out of the box with ‘%taxonomy_name’. Just make sure you’re using the official taxonomy name, not the display name or custom slug. Hope that helps.

    Under “Global Settings”, check “In case that you would like to replace the box title with the template title.:
    Replace the box title”

    What exactly is “$_POST[‘_title’]”? Is “_title” a custom field you’re filling in? If so, why not just use wordpress’s title instead of the custom field?

    Try commenting out your function and replacing it with “print_r($_POST);” or “var_dump($_POST);”. When you click “publish” in wordpress, it will take you to a page where it write out the entire contents of the $_POST array, so you can see what values you have available to work with.

    Lastly, try changing “$title_to_ignore” to “$my_post_title”? I haven’t tested it, but it looks like in your example if post type is NOT my_event, you’re attempting to return a blank string. Maybe this would prevent wordpress from allowing you to save at all?

    I just tackled this problem as well, so I’ll post this for anyone wondering the same thing.

    I’m not sure about it not being called at all (not activating print_r() — this worked for me). However, at first I thought it wasn’t being called as well. The real problem was that I was trying to use get_post_meta() to pull terms from custom fields, but the post hadn’t been saved in the database yet. I got around this by using the $_POST array to collect the same information. Here’s the code I ended up using:

    add_filter('name_save_pre', 'save_name');
    function save_name($my_post_name) {
            if ($_POST['post_type'] == 'parties') :
              $party_date = $_POST['date'];
              $party_name = $_POST['post_title'];
              $my_post_name = $party_name . "-" . $party_date;
            endif;
            return $my_post_name;
    }

    This checks to see if the post type is ‘parties’, and if so, it modifies the post slug (URL) to add the date to it. It seems to be working without error so far.

    Ah, that was fast. Here’s the code I’m using. It’s working perfectly

    add_filter('name_save_pre', 'save_name');
    function save_name($my_post_name) {
            if ($_POST['post_type'] == 'parties') :
              $party_date = $_POST['date'];
              $party_name = $_POST['party_name'];
              $my_post_name = $party_name . "-" . $party_date;
            endif;
            return $my_post_name;
    }

    I check to see if the post type is ‘parties’, and if so I change the URL based on two custom fields called ‘date’ and ‘party_name’.

    Again, I just hacked this together, so someone let me know if there are any potential problems with the way I’m achieving this.

    kangaechigai, your solution works… except it only works when the post is being updated. (I.E. It doesn’t work when I first click “publish” for a new post. I have to click “publish”, then click “update” for it to work).

    I think the problem is get_post_custom() is polling the database, but this data hasn’t been saved yet since ‘name_save_pre’ fires BEFORE the data is stored in mySQL.

    I’m far from an expert here, but I think it’s possible we can access all of this data from within the $_POST array… I’m going to hack around with it, and post here if I figure anything out.

    Ah ok. I found a hack here:
    http://shibashake.com/wordpress-theme/add-custom-taxonomy-tags-to-your-wordpress-permalinks

    Here’s the code I’m using:

    // custom taxonomy permalinks
    add_filter('post_link', 'location_permalink', 10, 3);
    add_filter('post_type_link', 'location_permalink', 10, 3);
    
    function location_permalink($permalink, $post_id, $leavename) {
            if (strpos($permalink, '%location%') === FALSE) return $permalink;
    
            // Get post
            $post = get_post($post_id);
            if (!$post) return $permalink;
    
            // Get taxonomy terms
            $terms = wp_get_object_terms($post->ID, 'location');
            if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
            else $taxonomy_slug = 'other';
    
            return str_replace('%location%', $taxonomy_slug, $permalink);
    }

    It’s a manual str_replace for my single taxonomy, “location”, but in this case it’s all I needed to complete my otherwise functional permalink structure.

    It may be more hassle than it’s worth to add the functionality to Custom Post Permalinks, but maybe this post will help someone else who needs the same thing. Thanks again for the plugin!

    Thanks — the problem was that I was using the display name.

    It doesn’t seem to be possible to use custom taxonomies in wordpress’s default permalinks (i.e. for regular posts, not custom post types). Is this something that would be easy to code into the plugin?

    Hi,

    “1.1 – Added support for all taxonomies”

    I can’t find an example on how to use this. If the post_type is “restaurant” and the taxonomy “location”…

    /restaurants/%location%/%restaurant% ?
    /restaurants/%taxonomy%/%restaurant% ?
    /restaurants/%category%/%restaurant% ?

    Thanks for the plugin — this makes custom post types a hell of a lot more useful!

Viewing 15 replies - 1 through 15 (of 15 total)