Wrapping add_query_arg with esc_url not working

And the strange part: both codes echo the same string for $url!!! No, they don’t. Look at the page source. esc_url() is encoding the & control character. You can’t do that and expect the HTTP request to work correctly. Use esc_url_raw() instead. Note the description in the Codex concerning that function: The esc_url_raw() function is … 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 );

how to get attached file url for current post?

try get_pages with ‘child_of’ => get_the_ID(), ‘parent’ => get_the_ID(), If you need i can post full code EDIT : if ( is_singular(‘post’) ) { $args = array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => null, ‘parent’ => $post->ID , ‘child_of’ => $post->ID, ‘sort_order’ => ‘desc’ ); $attachments = get_pages( $args ); if ( $attachments … Read more

How to use title attributes in sidebar widget?

You’r missing $post variable ( it is not defined and that for you don’t get post_name ). As a solution you could add global $post; You’r code would be like: <a href=”https://wordpress.stackexchange.com/questions/201956/<?php echo site_url(“/article/full-text/’); global $post; $slug = $post->post_name; echo $slug; ?>” title=”<?php the_title_attribute(); ?>”>Full Text</a>

Use wp_redirect to add a parameter

Use add_query_arg to make sure the url is created the right way. How is the wishlist link outputted? Trough wp_nav_menu? I would add it to the link on creation, so you don”t have to use wp_redirect.