Running non-WordPress PHP files

To run non-WordPress PHP files in a subfolder alongside a WordPress installation, follow these steps to modify your .htaccess file: Choose a Subfolder Name: Decide the name for your subfolder, e.g., mycustomphp. Modify the .htaccess File: Add the following lines above the # BEGIN WordPress section to exclude your subfolder from WordPress’s URL rewriting: RewriteEngine … Read more

Make category page the wordpress homepage (not blog)

This happens because WordPress doesn’t have provide multi-lingual functionality by default. When you call get_category_link( 22 ), you’ll get exactly that – the link for category with the ID of 22. WordPress isn’t aware that there might be a translation for the term and it should be used instead. The multi-lingual support needs to come … Read more

WordPress post slug redirection

You can use the next PHP code: // NAV: Custom Redirect function wpcoder_custom_redirect() { // Check if the current URL is the one you want to redirect if (is_single() && is_main_query() && get_post_field(‘post_name’) === ‘news-from-new-york’) { // Define the new URL $new_url = home_url(‘/news-from-new-york-2/’); // Get the query string from the current URL $query_string = … Read more

Where to add wp_redirect on frontend pages?

I found that currently this is the only reliable solution: if (is_admin()){ header(‘Location: ‘. get_permalink()); exit(); } else add_action(‘template_redirect’, function (){ wp_redirect(get_permalink()); exit(); }); In the case of backend pages the template_redirect does not seem to be supported. If I use wp_redirect the redirection does not happen (maybe it is a bug) or the function … Read more