Change permalink to attachment

If you change the structure of the permalink, you have to provide the rewrite rules to understand the new structure. Also, you are not building the attachment permalink correctly. The next code is working: add_filter( ‘attachment_link’, ‘wpd_attachment_link’, 20, 2 ); function wpd_attachment_link( $link, $attachment_id ){ $attachment = get_post( $attachment_id ); // Only for attachments actually … Read more

Using page as front page, why does /page/### work?

In WordPress you have 3 main kind of “views”: singular pages archives search “Standard” home page is just a somewhat special archive page, a static front page a somewhat special singular page. When you use the endpoint page in front page url, WordPress internally sets the query variable page to a specific number (would be … Read more

How to rewrite URL and get the values?

The simplest and quickest solution would be to use the add_rewrite_endpoint function. <?php add_rewrite_endpoint( $name, $places ); ?> So in your case it would be something like this: add_rewrite_endpoint( ‘user’, EP_PERMALINK | EP_PAGES ); An user URL would look like this: http://www.example.com/my-page/user/john To access the variable: $user = get_query_var( ‘user’, false );

optional parameter in permalink structure

Update You can make use of the add_rewrite_endpoint: add_rewrite_endpoint( ‘schools’, EP_PERMALINK | EP_PAGES ); You can then check in the sidebar for the schools variable: global $wp_query; if ( isset( $wp_query->query_vars[‘schools’] ) ) { // … } What is worth mentioning is that your URL will look like www.example.com/performance/name-of-performance/schools/ instead of having schools immediately after … Read more