php - Redirecting specific (but a lot of) URLs to include specific text -


the problem:

first of site using wordpress. using facebook sharer on lots of links include # or fragment identifier in url. problem facebook sharer doesn't allow , stops link.

for example if link is: example.com/europe/#comment-123

the facebook sharer change to: example.com/europe

i have been able change facebook sharer url display following: example.com/europe/123 achieved using code within "[url]=" part of facebook sharer code:

<?php echo esc_url ( get_permalink()); ?><?php comment_id(); ?> 

one way have tried solve problem trying echo "#comment-" using code:

<?php echo esc_url ( get_permalink()); ?><?php echo "#comment-" ?><?php comment_id(); ?> 

but once again facebook sharer stops displaying.

desired solutions:

1) if knows code allow facebook sharer hyperlink fragment identifier

2) read elsewhere possible solution redirect. if can facebook sharer display url of example.com/europe/123 , can redirect example.com/europe/#comment-123 fine. need happen on comments, no matter page, whether example europe asia or africa, whenever follows number if automatically puts "#comment-" before number

however, if have several pages in form of example.com/europe example.com/asia etc etc i'd imagine become more difficult.

have tried urlencode()

urlencode('example.com/europe/#comment-123'); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -