Redirect a list of URLs to another URL, using functions.php

What I wish to do I have a number of WordPress URLs I need to redirect, along with a 301 permanent redirect header being sent to browser. The URLs to redirect are: https://www.mydomain.com.au/search-result/?location=victoria https://www.mydomain.com.au/search-result/?location=new-south-wales https://www.mydomain.com.au/search-result/?location=queensland https://www.mydomain.com.au/search-result/?location=south-australia https://www.mydomain.com.au/search-result/?location=tasmania https://www.mydomain.com.au/search-result/?location=northern-territory Where to redirect to I want to redirect them to the home page: https://mydomain.com.au/ I am not … Read more

Redirect subdomain homepage to domain specific page in wordpress multisite

I have a wordpress multisite with one site to domain.com and another to materials.domain.com At the domain site I have a page domain.com/materials I’d like to redirect the materials.domain.com homepage to the domain.com/materials I’m using a child theme to my subdomain instalation and trying the following on functions.php wp_redirect(home_url(‘https://domain.com/materials’),301); exit; Now when I access the … Read more

Can’t get rewrite rules working

Basically I want to rewrite: /edit/test-post to an existing page with a parameter: /edit?e=test-post From the examples in the Codex I created: add_filter( ‘rewrite_rules_array’,’my_insert_rewrite_rules’ ); add_filter( ‘query_vars’,’my_insert_query_vars’ ); add_action( ‘wp_loaded’,’my_flush_rules’ ); // flush_rules() if our rules are not yet included function my_flush_rules(){ $rules = get_option( ‘rewrite_rules’ ); if ( ! isset( $rules[‘(edit)/(\d*)$’] ) ) { … Read more

Cannot modify header information – headers already sent by pluggable.php

I’m trying to develop a simple plugin but I’m having a problem: I have a custom WP_List_Table in an admin page, but when I click on a button like “Edit Row” or “Delete Row” it performs some expected action and try to refresh the page using wp_redirect(). This is causing a problem: Warning: Cannot modify … Read more

Redirect users away from Admin breaks ajax

Tried to make a simple redirect for some users I don’t want to access the wp-admin/, so I did this code: function no_admin_access() { if ( !current_user_can( ‘delete_posts’ ) ) { wp_redirect( site_url( “https://wordpress.stackexchange.com/” ) ); exit; } } add_action(‘admin_init’, ‘no_admin_access’); But when I then try to make a ajax request with those users, the … Read more