Welcome to WebmasterWorld Guest from 3.82.52.91

Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

the permalink doesn't show paginated urls?

     
7:03 am on May 19, 2015 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:July 29, 2007
posts:1859
votes: 113


I made a quick and dirty twitter share button and thought it worked great, until I happened to try to share a page from a multi-page post. The url reported by the_permalink is always the first page of any multi-page post, it ignores all of the pages after the <!--nextpage-->.

<a href="https://twitter.com/intent/tweet?url=<?php urlencode(the_permalink());?>&text=<?php the_title(''); ?>" target="_blank"><img src="/images/twitter-share.jpg" alt="Tweet This" width="59" height="59"/></a>


example.com/random-page
example.com/random-page/2
example.com/random-page/3

etc all return example.com/random-page in the button, the page number doesn't appear. I noticed the same thing happens to the open graph url data for this site so do I have a problem with my site or is the page number simply not added on nextpage posts via the_permalink?
8:04 am on May 24, 2015 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 19, 2006
posts: 169
votes: 0


I also have the same problem, but for me it's the index homepage which lists the last 10 posts and the 10th post is the one shared rather than the index URL.
I use similar code to yours and I haven't found a fix so far.
2:03 pm on May 24, 2015 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4166
votes: 262


That is the nature of a "Permalink". Each Page or Post is given a permalink that is derived from its Post ID and the permalink settings you specified during setup or customization. There may be a different code that could be entered in the link, in place of "(the_permalink())" but I don't know what to suggest, especially for paginated posts. Maybe hard code the uri of the page you want to link to?

You don't want to have a link to example.com/index.php anywhere, it works against the server and the default WP htaccess rewrite for the canonicalization for your site. A link to example.com/ should show example.com/index.php by default.
2:58 pm on May 24, 2015 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 19, 2006
posts: 169
votes: 0


I don't think hardcoding in the link would work well I'm afraid.

It would mean that the pages and posts would then share the index page, instead of the url of the post or page, as this code snippet is included in the templates.

Has anybody come across this problem?
5:05 pm on May 24, 2015 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4166
votes: 262


I had the understanding from the OP that this was not related to some plugin for social media but a custom built link. No, of course you don't want to create a link for all content to the home page. Your question did not mention that you are using a plugin or template with some built in setting. For that I would be looking for a replacement with more or better options. I apologize for the misunderstanding. For a custom implementation as shown in the OP the suggestion may be helpful.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members