Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7752325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:46:15+00:00 2026-06-01T11:46:15+00:00

I have a static front page in WordPress and I want to use a

  • 0

I have a static front page in WordPress and I want to use a city name in the permalink so that I can change the contents of the page on the basis of the detected city. However, when I try to add a rule, it takes me to the wrong page. Here is a sample of the code I’m trying to use:

$wp_rewrite->add_rule('^city-([^/]*)/?$','index.php?cityNameParma=$matches[1]','top');

It’s for a page which will display businesses directory listings. Upon clicking I added a new rule
which should allow inner pages to work as intended:

$wp_rewrite->add_rule('^city-([^/]*)/wpbdm-category/([^/]*)/?$','index.php?wpbdm-category=$matches[2]&cityNameParma=$matches[1]','top'); 

I then get the city name from the URL with

$wp_query->query_vars['cityNameParma'];

The only problem that remains is how to get the value when a static home page is called and how I send the parameter value as I have done for inner pages.

Kindly help me out as I have melted my brain.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:46:17+00:00Added an answer on June 1, 2026 at 11:46 am

    i think you also have to add your new parameter to the accepted query-params:

    function my_query_vars( $qvars )
    {
        $qvars[] = 'cityNameParma';
        return $qvars;
    }
    add_filter('query_vars', 'my_query_vars');
    

    then you can access it in your template files like you described:

    global $wp_query;
    $wp_query->query_vars['cityNameParma'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have configured WordPress to display a static front page as described here: http://codex.wordpress.org/Settings_Reading_SubPanel#Reading_Settings
I have a static page set up as my front page for Wordpress. I
I have a static page set as front page in Wordpress, instead of default
In WordPress 3 I've set up a static front page (called Home). I need
I want to use clientIDMode=Static in the web.config as it's awesome for front end
On my front end, I have following functions: method to encrypt: public static string
I have static method which returns me as it's name says data from domain
Suppose I have static ip in a subnet that has DHCP server. If i
Why can we have static final members but cant have static method in an
I have a static method in my code that I would like somehow to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.