Results 1 to 4 of 4

Thread: Detect if default permalinks are active?

  1. #1
    dgwyer's Avatar
    dgwyer is offline Tavern Regular
    Join Date
    Jun 2010
    Location
    London, UK
    Posts
    230

    Default Detect if default permalinks are active?

    Had a quick Googly around but didn't see anything on this. Need it for a new plugin I am working on.

    Does anyone know if there is an easy way (i.e. existing function) to detect if a WordPress site is using default permalinks or custom?

    I know I could look up the current page URL and see of there is a '?' after the domain name. for example: http://localhost/wordpress3.0/?page_id=4. It is quite easy to check ther URL for the '?'. Bit of a hack but it should work OK - however if there is a better way I would rather use that.

    David

  2. #2
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    I assume (but haven't checked) that the current permalink setup is stored in the options table, so you should be able to access it via get_option ('something or other' );

  3. #3
    Ipstenu's Avatar
    Ipstenu is offline Big Tipper
    Join Date
    Feb 2010
    Posts
    368

    Default

    You could check the value of permalink_structure in the table wp_options, via SQL.

  4. #4
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    If it's in that table, then you should be able to access it via get_option like I suggested above ... off to confirm ...

    EDIT: Yes, the following will work:

    PHP Code:
    get_option'permalink_structure' ); 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •