Use add_query_arg() to do this.
Here’s a useful function if you need to get the current page URL (when get_permalink is inaccesible, like on Archives):
function get_current_page_url() {
$request = esc_url($_SERVER["REQUEST_URI"]);
$pageURL = (is_ssl() ? 'https' : 'http').'://';
if ($_SERVER["SERVER_PORT"] != "80") $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$request; else $pageURL .= $_SERVER["SERVER_NAME"].$request;
if (false === strpos(get_option('home'), '://www.')) $pageURL = str_replace('://www.', '://', $pageURL);
if (false !== strpos(get_option('home'), '://www.') && false === strpos($pageURL, '://www.')) $pageURL = str_replace('://', '://www.', $pageURL);
return $pageURL;
}
Related Posts:
- Enabling Sessions in WordPress 3.0
- How to let a single post have its own domain name
- simple wp_insert_post example
- WordPress change author email notify message?
- Set user loggin status?
- How to remove tag cloud from taxonomy admin edit page?
- Access post meta in future_to_publish function
- Author Tracking Code!
- Problem with custom function from jQuery slider tutorial
- Different profile page by role
- Add array of post id’s to a category?
- Backup the Database and Restore from the Backup?
- Scaling a WP eCommerce site
- Looking for a lightweight theme using WP3 new tags and features (not 2010) [closed]
- Limit Media Library to Given Folder
- How can I get posts in a subcategory to display on it’s parent categories archive page?
- customize_register with Multiple controls/settings – how to get values?
- Integrating the WordPress admin panel with a frontend theme
- Redirect members to custom page upon logging in through WP admin
- Integrating MailChimp newsletters as post
- Remove “Parent” Selection When Adding/Editing Categories?
- Allow role to delete posts but block him the wp-admin
- Programmatically add a custom page/path/url/route to WordPress
- Get multiple db prefix with $wpdb
- Importing media medium setting image gallery / image attachments
- How do I remove the eye icon that shows visibility on login screen and reset password screen
- Could not create directory. /var/www/html/wp-content/plugins/PLUGIN_NAME/
- Unique User Account Number + Displayed Via Shortcode
- How can I add Google’s reCaptcha to Divi’s contact form module? [closed]
- How do I copy all “extra” data (menus, widgets, etc) from one theme to another?
- Fatal error in wp-admin/customize.php after fresh install due to null $wp_customize
- Adding a login form that concatenates three fields into a username
- Right way to update widget on dynamic new input field
- Moving from development while pulling production database without overwriting, to production
- Ability to only view (not edit) other user’s personal profile information
- Fastest way to get the comment and ping total count for a post
- Is it possible to add a ribbon in the background of h1 on every page?
- How to add textarea field to taxonomy (tag)?
- changing font size and font of a custom message added after comment
- Custom wp-content and upload directory
- Lost password empty field error redirect to custom login
- Custom comments list, right depth
- Order posts with a custom field but also without
- WordPress Custom File Permalink
- WordPress 3.0.1 on IIS 6 Web Server PermaLink Issues
- Extend WordPress Core Classes in OOP Theme?
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- how to display a specific wordpress menu?
- User bar above logotipo?
- Create a url structure for my blogs based on categories and sub-cats
- Can I integrate wordpress with my current website so I can utilize the wordpress plugins?
- Change Notice of Password change email subject?
- Deleting my old WordPress site. – issues
- Dynamically Filtering Posts by Data Points – Any Pointers?
- Woocommerce custom checkout form
- Remove year from title
- Custom Tags Archive – permalinks not working
- How to append custom text to the output of ‘categories widget’?
- How to assign a custom post title to be the post ID?
- Creating custom page template
- Which delete query is better with prepare or delete
- Change Site Logo or Menu Logo Per Page
- How to add page content into another page
- Remove Sidebars from page
- WP Search Form Query: Add Author’s posts into search query
- Creating a “Delete”-Button for Metadata userspecific
- Change default Video Player without Plugin
- Changing update message from Newspaper child theme
- export and import wordpress customization
- implement custom roles in custom plugin
- where is admin footer?
- How can i add customisation of text to my theme?
- Can I overwrite custom taxonomy FROM “public” TO “false”
- Trying to customise 2011 Child Theme Background Colour
- New Page/Post Screen Opens an Existing Post
- Custom product status get filtered on all product list views
- the temporary save folder is wrong
- URL issue after setting up Custom Structure in Settings >> Permalinks
- Can I upload my self hosted WordPress website on GitHub as a project? [closed]
- Need to replace some text string on a title
- Cannot go to next page on phone but can on computer
- How to hide or remove a custom widget area when empty
- True email confirmation for registration (keeping unvalidated users from user table)
- Create single{custom}.php with data in table out of wp_posts
- How do i edit text that is not in the customization menu
- How do I map two domains to the same wordpress installation?
- Best way to replace image url with source
- Where should I put this custom data?
- Multiple Taxonomies Using Custom SQL Query
- Changing starting number of User ID
- how to register / add multiple options into one field in wordpress?
- How to duplicate “Pages” section in the control panel?
- WordPress Customize panel – accessing the values
- Pull certain WordPress posts on custom CMS instead and 301 wordpress to it?
- Create users via PHP
- Show post content in two different places without redirect
- Multiple Customizers
- how do i add logo in my site
- Show total sales for each products on search results page Woocommerce
- Custom Search on media files PDF images pages posts