Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Properties of class WP_Rewrite

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 112
    Comment on it

    Welcome to FindNerd.

    Today we are going to discuss the concept of rewrite rules in word-press. It is little confusing for  lots of developers but  if we check different methods of WP_Rewrite class then you can easily implement them in projects. Word-press provides class WP_Rewrite which contain methods and properties to implement the rewrite. Before we start with functions what i want to clear the concept of rewrite rules. Rewrite rules are helpful to change or modify the URL structure. If you work on word-press then you should be familiar with permalinks. Word-press provides different URL structures. With rewrite rules we can create new or custom permalinks. Now we will talk about the properties of WP_Rewrite class first. Please have a look.

     

     

    Property Description
    $permalink_structure This variable stored the current selected permalink and its value is also stored in database. You can get the current active permalink by using this code. global $wp_rewrite; var_dump($wp_rewrite->permalink_structure);
    $category_base Useful to insert text before the category archive URL. Default value is set to be 'category/'
    $category_structure It is known as, combination of category base and '%category%'. it denotes the category archive structure.
    $author_base Useful to insert text before the author archive URL. Default value is set to be 'author/'
    $author_structure It is a combination of author_base and '%author%' and it denotes the structure of author archive URL.
    $pagination_base Useful to insert text before the pagination pages and default is 'page/'.
    $feeds It represents the feed names like atoms, rss and rdf.
    $feed_base Useful to insert the text before the feed URLs. Default is set to be 'feed/'
    $feed_structure It is a combination of feed_base and '%feed%'. Represent the structure of feed URLs.
    $search_base Useful to put the any thing before the search URL. Default is set to be '/search'
    $search_structure Represents the structure for the search URLs. it is known as combination of search_base and '%search%'
    $comments_base Useful to put any thing before the comment URLs. Default is set to be 'comments/'
    comments_feed_structure Represent the comment URLs structure and it is combination of comments_base and '%feed%'.
    $date_structure Represents the dated archive structure.
    $page_structure Represents the page and set to '%pagename%'.
    $front Represent the text up to the start of the first tag in our $permalink_structure.
    $root Represent the root of Word-Press and Prepended to all structures.
    $matches Used for the redirect part of rewrite rules.
    $rules rules is set by rewrite_rule() function
    $non_wp_rules Non word-press rules which are not handled by the word-press and it puts in an associate array.
    $rewritecode It represents the  array of available tags for permalink.
    $rewritereplace we set the rewrite rules with regular expression and replace the tags accordingly.
    $queryreplace Each tag will be replaced within the rewrite part of the rewrite rule.

     

    In our next blog we will discuss the different available methods one by one in class WP_Rewrite. You can check different properties of the class WP_Rewrite. Thank you for being with us.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: