Reputation: 158
I'm relatively new to PHP and still getting the hang of what's possible. So I'm setting up a custom WordPress theme for my website's blog, designed to look exactly like the website, except displaying appropriately styled WordPress posts in the main section.
Here's where I'm trying to do something tricky: I've set up a horizontal nav menu that looks like tabs above each individual post. When the post is being viewed, the post tab is in the foreground. The other tabs are for Twitter, FB, and a print option. I want it to be possible for a user to click the twitter tab, and have the twitter share box and/or sign-in page appear within my website (without using frames obviously). Twitter doesn't seem to have a ready made widget for it, but I think it should be theoretically possible by maybe using a <?php include ?>
statement. But I don't know, I'm not even sure where to start looking for info on how to accomplish this. At very least, I want to display the twitter site within the tab upon redirect.
Either way, the benefits are obvious: The user doesn't have to leave the site, close new tabs, and have the back button broken etc. The image tells you more than the code can, but image uploading is being a pain right now and I'll have to try again later when I have more time.
In case I didn't adequately describe what's happening, the tabs, which reside above every individual post, should all operate like browser tabs. This means that if you click it, you don't go to a different site, but the twitter share box opens up right there, in place of the post.
Upvotes: 0
Views: 544
Reputation: 570
Are you trying to just have the tab link to a separate page? If you are, you can just grab the Twitter widget from their goodies page (http://twitter.com/about/resources/widgets/widget_profile) and customize it to fit your dimensions and username.
EDIT: I understand now. At first I thought you wanted a way for users to quickly switch between seeing your posts and viewing your tweets. To do what you wanna do, check out the Twitter API (https://dev.twitter.com/docs/tweet-button). If you use a code like the one below, it'll automatically detect the page name and link:
<a href="https://twitter.com/share">Tweet</a>
Or if you wanted to be a bit more fancy, you could use something that detects the title of your post, the url, and implements YOUR Twitter username. Here's something I whipped up really quick, just put it into your Wordpress theme where you want it to display:
<a href="http://twitter.com/share" target="_blank" class="twitter-share-button" data-url="<?php the_permalink(); ?>" data-text="<?php the_title(); ?>" data-count="horizontal" data-via="[INSERT_YOUR_USERNAME]">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
I think this'll help you do what you want, it doesn't do it in place of the post, but it does open up in a small window.
-Matt
Upvotes: 1