Title: WP_Rewrite::get_search_permastruct
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Rewrite::get_search_permastruct(): string|false

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#description)
 * [Return](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#wp--skip-link--target)

Retrieves the search permalink structure.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#description)󠁿

The permalink structure is root property, search base, and finally ‘/%search%’. 
Will set the search_structure property and then return it without attempting to 
set the value again.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#return)󠁿

 string|false Search permalink structure on success, false on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#source)󠁿

    ```php
    public function get_search_permastruct() {
    	if ( isset( $this->search_structure ) ) {
    		return $this->search_structure;
    	}

    	if ( empty( $this->permalink_structure ) ) {
    		$this->search_structure = '';
    		return false;
    	}

    	$this->search_structure = $this->root . $this->search_base . '/%search%';

    	return $this->search_structure;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-rewrite.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-rewrite.php#L691)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-rewrite.php#L691-L704)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#related)󠁿

| Used by | Description | 
| [get_search_comments_feed_link()](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/)`wp-includes/link-template.php` |

Retrieves the permalink for the search results comments feed.

  | 
| [get_search_link()](https://developer.wordpress.org/reference/functions/get_search_link/)`wp-includes/link-template.php` |

Retrieves the permalink for a search.

  | 
| [get_search_feed_link()](https://developer.wordpress.org/reference/functions/get_search_feed_link/)`wp-includes/link-template.php` |

Retrieves the permalink for the search results feed.

  | 
| [WP_Rewrite::rewrite_rules()](https://developer.wordpress.org/reference/classes/wp_rewrite/rewrite_rules/)`wp-includes/class-wp-rewrite.php` |

Constructs rewrite matches and queries from permalink structure.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rewrite/get_search_permastruct/?output_format=md#changelog)󠁿

| Version | Description | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rewrite%2Fget_search_permastruct%2F)
before being able to contribute a note or feedback.