Multisite Global Permalink Configuration

I'm setting up a Wordpress Network and wanted all new sites to have the same permalink structure (i.e. "/%year%/%monthnum%/%postname%/"). I'm wondering if this is possible to do via hooks or hacks in functions.php, without having to rely on users to choose that structure.

Replay

You can set the permalink structure by calling on the set_permalink_structure() method of the global $wp_rewrite object.

add_action( 'init', function() {
    global $wp_rewrite;
    $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
} );

Here's a PHP < 5.3 version of the code in case you're getting errors.

function reset_permalinks() {
    global $wp_rewrite;
    $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
}
add_action( 'init', 'reset_permalinks' );

Category: theme development Time: 2011-10-15 Views: 1

Related post

  • WordPress Multisite - global categories 2011-03-16

    Setting up a WP multisite instance - the client has an existing ontology / set of categories that they want to classify all content across the set of blogs. Also the desire is that any new categories would be added at the 'network blog' level and syn

  • Creating a global Vim configuration, including separate configuration files for plugins? 2013-09-29

    I use Arch Linux (ARM, but irrelevant) on a server machine, and I want to create a global configuration for Vim, based on my current personal configuration. I have already moved my ~/.vimrc to /etc/vimrc, and that works fine, but I want to configure

  • In Centos, where is the default or global tmux configuration files stored? 2013-10-31

    I haven't used tmux in awhile and I forgot where is this installed. how can I find out where this is installed and which default / global configuration file is being loaded? --------------Solutions------------- Just do 'rpm -ql tmux' to see all the f

  • Multisite Global Custom Posts 2015-12-07

    I have a museum client with a multisite setup with pages that detail the exhibits in their facility. They recently added tablets throughout the museum and want their tablets to display only their exhibits (no other extraneous pages from the main site

  • Determine if aws-sdk is has global credentials configured 2016-01-27

    From the information provided in the AWS SDK config guide there are multiple ways to configure the SDK: Loaded from IAM roles for Amazon EC2 (if running on EC2), Loaded from the shared credentials file (~/.aws/credentials), Loaded from environment va

  • How can I create a multisite global tag cloud? 2010-12-23

    I have a WordPress multisite installation. I need to create a sitewide tagcloud on the main blog. How can I do that ? --------------Solutions------------- Use this plugin http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/ and this tutori

  • Global filter configuration 2016-07-15

    I have been trying to set up the "Global Filter" module but struggling. I cant seem to find where I set the field or view which will be use to filter. I have attached a screen shot of the settings page. Am I missing something?

  • Multisite Subdomain Permalinks 2016-07-01

    Hello ive ben struggling to get this sorted and i dont even know if it can be sorted. i will try my best to explain. www.mainsite.com -www.site1.com -www.site2.com When i create content on either site the permaink/slug looks like this- www.mainsite.c

  • Global searchin multisite but only with one subsite 2011-07-04

    I have a multisite set up with currently 2 subsites. Is it possible to have a search box that searches the main site and just one subsite? --------------Solutions------------- Perhaps you can use this plugin: http://wordpress.org/extend/plugins/multi

  • how to make the configuration .emacs to be global in linux 2016-02-01

    what I mean is that I've had a .emacs file in my /home,but when I cd ,for example,/etc/profile,the configurations which are written in the .emacs make no sense.So I want to know how to make the .emacs to be global. Thank you:) --------------Solutions

  • How to reliably flush rewrite rules on multisite? 2015-05-08

    Let's say you have a plugin which need to flush rewrite rules. You do it all properly with activation hook and adding flush late, so everything is smooth and compatible. And then one fine day someone tries to run it on multisite. Instead of a simple

  • Multiple sites with pretty permalinks with nginx 2012-02-14

    I'm trying to set up a new local development server and instead of Apache I've decided to go with nginx. What I'd like to do is have each WordPress site live within its own directory inside /usr/share/nginx/www. The sites are only going to available

  • How to use permalink query to go to specific tabs in posts 2012-04-05

    I'm not really sure how to phrase the questions, but hope it's not too confusing. Basically I've create a plugin which inject custom tabs into the posts content when displaying. For now, just assume I'm using DomTab, and I have permalink configured a

  • Different permalink for CPT and regular Posts/Pages but why? 2014-03-25

    Permalink structure in Back-end: http://domain.com/%year%/%category%/%postname% For "regular" Posts/Pages all is okay but as soon a CPT is shown %year% is gone? Url shown for Posts/Pages looks some like: http://domain.com/2014/category01/regular

  • New Site URL for Multisite 2015-02-03

    I want to create new networks but am having issues because Wordpress is saying it is invalid. I have a base url of something like http://website.com and then I'm trying to create a new network after that. I'd like my new networks to have a name like:

  • WP Permalinks won't work without DNS in nginx (ip/folder) 2015-11-04

    I am trying to access some of my websites via http://ip.add.re.ss/domain.com so my client can update the website content BEFORE putting it online (pointing the DNS) The website is stored in /var/www/domain.com. The frontpage loads ok, but none of the

  • Global (computer-wide) proxy settings from pac file 2010-01-23

    Our company just changed proxy settings from using one proxy server to a bunch and inserted pac files to IE settings. The problem is, any software that doesn't allow setting proxy script (pac file) explicitly, can't get online any more. I wanted to s

  • What is the order of precedence for RedHat network configuration files? 2010-10-10

    This has been bugging me for some time, because I haven't bothered to sit down and write down what exactly is going on. Our RedHat server network configuration is all over the map. Across a fleet of servers installed RH4 and RH5, sometimes we manage

  • wp_insert_post generated mixed permalinks 2012-04-03

    I'm writing a plugin which uses wp_insert_post() to insert posts programatically and my permalink setting is /%category%/%postname%/ Of all the post inserted, wp_posts.guid shows 2 types of output. Some post will be following /%category%/%postname%/

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.308 (s). 13 q(s)