I am not entirely sure what you are asking but that ?p=
pattern is a raw query string. That is, that is what you get without pretty permalinks at all.
Go to Settings->Permalinks in wp-admin and select the default permalinks. Save and you are done. You don’t need any other function. If that doesn’t solve it you need to rewrite your question so that it is more clear.
Related Posts:
- Date based URLs for custom posts and pagination
- Add ‘articles’ prefix before blog posts url without affecting pagination
- How to handle paging/pagination with a custom permalink?
- Pagination links for taxonomy archive page 404 error on every page except first
- Need help with add_rewrite_rule
- How do I add /blog/ as a prefix to permalink structure for blog posts, tag pages, etc.?
- Permalink format: singular or plural
- Get current URL (permalink) without /page/{pagenum}/
- Pretty permalinks for search results with extra query var
- How to get pretty URLs with add_query_arg in permalinks
- Custom post type permalink endpoint
- URL rewrite based on a custom field value
- Changing the URL Structure of a Paginated Custom Post
- How to change author base without front
- How to create a permalink structure for posts in a specific category
- How to map permalinks with accented letters to sanitized slugs?
- Add custom directory in URL
- Using two permalinks for one post
- Custom rewrite rules for a $_GET request
- Nice RSS Feed URLs for each custom post type
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- Put post ID on the custom post type URL
- Rewrite url / permalink for default archive – yearly / monthly
- Random Alphanumeric Key URLs
- Permalinks, Rewrites, Get Variables, Oh My!
- Change permalink for a single post entry
- Remove the Parent category from the permalink but leave the child category
- Apostrophe in permalink results in page not found
- Change permalinks with ACF values
- Can’t get rewrite rules working
- Multilanguage URLs
- Rewrite my default post URL
- When is it a good idea to build a permalink structure from scratch?
- How to reset canonical URLs / fix redirect loop
- Attachment Page Permalink/URL Rewrite Issue. How to change the actual rewriting?
- Permalinks: Page Not Found
- wp_logout_url redirects to incorrect page because of pagination
- Does changing a post title of a published post automatically change permalink?
- How to Get Page 2 / Paginated RSS Feed with Custom Permalink Structure?
- Remove custom taxonomy base from URL
- Is a permastruct possible on pages?
- Rewrite rule for a query string
- How to add a variable as a tag base?
- WPML – how to get the permalinks to display also the default language
- Why is page/2/ not working?
- How can i have a custom post type with more slugs for each post?
- URL rewriting: removing the site’s basename for a specific category
- Rewrite rule intended for CPTs gives 404 for pages
- Unable to get /%postname%/ permalinks working, 404 on all links
- Permalink structure between 2 custom post types and a taxonomy
- Disable date based archives for all categories except one
- How to rename ‘Tag Base’ with WPeC 3.8?
- Custom rewrite rule ignored
- How can I emulate permalink behaviour on static pages
- Remove parent page from url
- Pagination using paginate_links
- add_rewrite_rule – Page Slug from “/foo-bar/” to “/foo/bar/”
- WordPress pages and posts are redirecting to server IP address instead of domain URL [closed]
- Access or edit custom generated permalinks with WP_Rewrite
- optional parameter in permalink structure
- Rewrite rule not passing variable
- “set_front” => false on custom post type breaks wp_list_categories links [closed]
- All in One Seo and Permalinks
- rewrite based slug standar post wp
- remove SLASH on single_post but KEEP on categories and parent pages
- WordPress keeps removing query var from the URL
- How can I access to the same post-type “page” from multiple different urls?
- Multiple URL rewrite rules and get every prams
- Using a template file for a specific custom URL
- Extra url paths as variable
- Passing parameter through permalink structure
- Add word to permalinks does not transform the urls
- Add slug to default post permalinks ONLY
- Added .html to Woocommerce permalink but pagination don’t work!
- My permalinks for all pages and posts now include old page titles as parents/categories
- Pretty Filter URL
- WordPress Pagination Custom Rewrite Rule for Pages
- How to change URL of my pages?
- How can I get .html URL suffixes in permalinks?
- rewrites and custom links in page need help with add_rewrite_rule
- Dynamically populate permalinks
- Converting WP Page to use full explicit paths?
- How to create an IIS7 re-write rule for a single category
- Add Custom Pagination Permalink
- Prevent guessing slug
- All pages lead to home
- Although rewrite engine is on, I get 404 not found on every page
- Remove index.php from WP 8.0 install migrated to IIS from Apache (still detecting Apache server)?
- Customize category permalinks
- Update permalinks
- Losing the original URL when using add_rewrite_rule
- Custom permalink variable on single post
- My wordpress site must be being affected by outside sources [duplicate]
- URL to an image in a post is changing when permalink is set to custom. Can I avoid this?
- how to create several url aliases for a page
- Permalinks, how to show them in post
- permalinks url with woocommerce
- How to get the perfect WordPress, WooCommerce, Custom Post Type pretty permalinks?
- Blog url disappears
- Blog URL Structure – Multiple Taxonomies