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' );
Related Posts:
- Get the blog page URL set in Options
- Different ways to display title
- How Do I Programmatically Force Custom Permalinks with My Theme?
- date_i18n() issue
- WordPress Multisite: Have the same header and footer of main-blog on all sub-blogs
- Display site admin profile fields in header.php
- How to test for MU via functions.php?
- Same footer on all multisites blogs
- Excluding a page with a certain name from wp_page_menu
- Link won’t show using the_permalink();
- get_query_var() and permalinks
- How can I disable/hide certain themes in multisite?
- Change the template of multiple multisite pages at the same time
- Is it a bad practice to use switch_to_blog in the frontend?
- WordPress custom post type permalink: website.com/post-name/post-id
- Theme Development for WordPress Multisite Installation
- WordPress empty Nav Menu error
- multisite: global menu containing network site links?
- Acivate all themes multisite wide automatically
- Filter categories used with Custom Structure Permalink
- How to make permalinks update from code?
- Question regarding WP multisite feature
- Default Permalink Type to Postname
- How to set a page as homepage in stead of the newspages?
- Featured Image meta box not showing up
- Where do files uploaded via Media Manager get stored in MU?
- wordpress 404 not found after rewrtie the author link
- Issue On Displaying Pages with Post Name Permalink
- Issue on Getting Custom post type Thumbnail’s URL
- WordPress page/blog incorporated into static website
- How to allow users to create their own website within my domain? [closed]
- Different text on different sites in a multisite setup
- Only the latest post shows up on post page?
- How to make a theme unable to be used on a multisite network?
- Sample Theme Options page for Multisite – what to consider
- Get themes’s images path in WordPress Multisite
- How to remove permalinks links presents in each page of my site?
- Multi Site Setup, Child Themes, Getting Style Sheet Directory
- Converting a theme to a child theme in a network
- HTTP Error when uploading images over specific dimensions
- If I remove Category base from my URLs, how difficult will rollback be?
- What are the permalinks options for “Category” base and removing it?
- How to get blog-id of an MU site from functions.php
- How do I open a post in a custom page in wordpress?
- Does single webpage do not need navigation to create a slug in permalink?
- Getting post URL within custom content template
- fetch all post from wp multisite network and sort all the post in descending order on the basis of “Created by ” term
- How to get full native language instead of iso?
- How to make menus, footer, sidebars multi language
- Why does the theme of secondary site load the primary one in WordPress Multisite? [closed]
- Let user publish posts on community page
- How to hide blog by id wordpress multisite listing
- Can I use WP Multi-site on a sub-domain with a different theme but use all the original site’s posts/pages?
- Mutlisite in wordpress is not working
- background_image support multiple image size?
- How can I demonstrate themes well?
- Theme Options Doesn’t Work On WP Multisite
- Mamp pro permalink issues. Pages keep reverting to index.php
- Subsite theme mystery man replacement with Buddypress on main site [closed]
- Custom link color or stylesheets
- Permalinks problem with custom theme
- Permalink Setting Changes From Post Name to Default After Changing The Page Name
- Configuring static page with add_rewrite_rule gives 404 after navigating to Permalinks admin panel
- How to remove dashicons.min.css from frontend?
- What’s the difference between home.php and index.php?
- get_template_part vs action hooks in themes
- Customize WordPress>Error Page
- Theme file for all pages that are a child of a specific page
- Strategy to get post meta for use outside the loop
- Authentication / login mechanism (non wp-admin)
- Am I using get_posts wrong?
- Writing Clean WooCommerce Styles
- retrofiting old blog
- Override parent theme’s include file from child theme
- WordPress add options to theme not displaying
- What is the right way to set up a one-page portfolio theme? [closed]
- Is it possible to edit the styling of the admin panel from within a custom theme?
- When trying to override plugin’s function by theme, my filter executes two times, I want it to run only a single time
- the_excerpt(); tag not working
- Storing the contents from txt file into The_Contents”
- One blog inside another
- wordpress multisite permalink structure: mostly subdomains but not all
- [&hellip appearing instead of […]
- How to have content scroll over background
- Need help with adding templates (archives and sitemap) to WordPress child theme
- WordPress does not load page template or anything else, just empty page with header and footer
- Managing wordpress Themes & plugins for multisite
- add shortcode support in customizer
- How to make my themes compatible with different WordPress versions?
- Custom search template is showing 404 when adding query string
- How do I restructure the comment HTML layout?
- url not using query string no longer working
- How to Show Next, Previous, and Page Numbers with wp_link_pages
- How would I get this to work – send to post from thick box
- Safe way to echo wp_trim_words
- How to using custom DB tables
- How to remove proudly created by WordPress in theme?
- My wordpress site memory exhausted more than 1GB trying to debug with default
- Display first post on each page differently than the others
- Image and font support missing in editor when deploying theme remotely