I'm helping out as admin on a WordPress site and we are adding the ability to "Like" individual post and pages and are using the following code;
<div class="fb-like" data-href=”<?php the_permalink(); ?>” data-send="false" data-width="450" data-show-faces="true"></div>
The Like button displays correctly but the url for some reason has an " added in the end rendering the link to become invalid. If I "echo" the result of the_permalink it displays the correct url.
Example;
Like is clicked on http://my.blog/is-cool/ but the displayed url on my timeline is http://my.blog/is-cool/".
Your double quote marks around the <?php the_permalink(); ?> are incorrect - they are the 'curly quotes'.
Related
I have run into a very interesting problem. I am working on a site for a client of mine and have run into this issue using Advanced Custom Fields no wordpress. I have added a new custom field to the site for their rewards program spot, and I am having trouble getting the url field to work corretly. I have the code added to the template php file that it needs to be in and it looks like this at the moment.
<div class="row">
<?php $ficvalue = get_field('free-icecream-url');
if ($ficvalue) {
$ficurl = esc_url($ficvalue);
}?>
<h3 class="heading" style="text-align: center;"><?php the_field('free-icecream-header'); ?></h3>
<a href"<?php echo $ficurl; ?>" class="btn btn-primary" style="max-width: 15em;"><?php the_field('free-icecream-btn'); ?></a>
</div>
When I put the url into the custom url field on the backend in the page editor, it doesn't appear in the anchor correctly. if I add this line to the page, it shows the url correctly on the page itself:
<?php echo get_field('free-icecream-url'); ?>
This will show the url as it is inserted into the custom field, however adding it into the anchor's href like this provides a different result.
<?php the_field('free-icecream-btn'); ?>
<!-- results as the following in chromes inspect -->
<!-- https: www.rococoicecream.com rococo-rewards
Instead of https://www.rococoicecream.com/rococorewards -->
I have tried to use esc_url() and esc_html() to no avail. and when using the_field() it yields the same results. What am I doing wrong?
The answer to my question here was answered shortly after posting it. I updated the original question but I will also place it here. I found the problem I was having was that I missed a = after the href in the anchor for my button. After finding that out, it works like a charm.
I have this href link which is dynamically posted, I want to get the single.php file and the dynamically posts to be redirected to my single.php file Here is my link below:
<a href="/single-<?php the_ID();?>-<?php the_slug(); ?>" class="wrapper" style="background-image:url('<?=$url?>')">
When I click on the link the URL is this way:
/single-137-2014-inaugural-diversity-abroad-conference-4
And I want that page to be redirected to my single.php file. How will I be able to do this?
Any help is muchl appreciated. TIA
I have solved your problem but please read about the get_permalink() function
<a href="<?php echo get_permalink(); ?>" class="wrapper" style="background-image:url('<?=$url?>')">
get_permalink() - Retrieves full permalink (link of a post) for the current post or post ID. This link will be opened post single page, which means if this is a custom post type and you create it as a separate single-post-type.php, then it will be as an open single-post-type.php page. Otherwise it appears as single.php.
For your information, posts have been opened in single.page while page opened with page.php. read about this link https://codex.wordpress.org/Post_Type_Templates
I would like to add a share link from my wordpress website to tweeter.
I found how to do it but, I would like to remove the twitter logo and add a simple text link.
So I removed the twitter class "twitter-share-button" but I can't retrieve informations into the twitter textbox...
Here is my code:
<a href="https://twitter.com/share" data-url="<?php the_permalink(); ?>" data-text="<?php the_title(); ?>" data-hashtags="hashtag" >THIS_TEXT_THAT_I_WANT_TO_DISPLAY and add all data content to the twitter text area</a>
<script>
!function(d,s,id){
var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){
js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);}}
(document,"script","twitter-wjs");
</script>
Thanks
You can build your own Twitter share URL. You don't need to include any javascript or the Twitter SDK, it's just an HTML link. More info on building your own at https://dev.twitter.com/docs/tweet-button, just scroll all the way to the bottom of the page. Try something like this for yourmarkup:
Tweet this
There are a lot of things you can pass into the url, so you can tweak this to get the result you're looking for.
Here is the result code:
Tweet this
Good Evening,
I'm using Drupal 6, CCK Module, and the Link Field Type. All are installed and activated.
I created a custom content type called Slider. A user can upload an image, a title, and a teaser. I created a custom field for that slider content type as well as one called Link with the field name: "field_link_test".
I created an entry, filled in all of the data including a URL for that link field type and clicked "Save". In views-view-table--slider.tpl.php, I added:
Learn More
but on the front end, everything shows except for that link. I also tried emptying the Drupal cache.
Any ideas?
Update template code below, which all works fine, except for the new link value outputs nothing.
<div id="slider">
<div class="slider-holder">
<?php foreach($rows as $row): ?>
<div class="slide">
<?php print $row['field_image_fid'] ?>
<div class="info-slide">
<h2><?php print $row['title'] ?></h2>
<p><?php print strip_tags($row['teaser']) ?></p>
Learn More
</div><!--INFO-SLIDE-->
</div><!--SLIDE-->
<?php endforeach ?>
</div><!--SLIDER-HOLDER-->
<div id="control">
</div>
</div><!--SLIDER-->
The easy possibilities (which you've probably checked, but just to get them out of the way):
you need to allow the field to be viewable by anonymous/authenticated users in User Management - Permissions
Otherwise, it's hard to tell without some code to analyse. Could you post your entire views-view-table--slide.tpl.php and if possible, your exported view or a link to the exported view?
EDIT
Now that I've had a chance to look at your view, I've made a couple of changes that should help.
The reason your link URL isn't showing is that you're including the "Node: Link" field in your View instead of the "Content: Link (field_link_test)" field. The first one will just link back to the original node rather than your custom link. Also, I don't think you can call the $node variable from views-view-table (at least, I don't get anything when I print it. Instead, you can use the $row variable.
I have a version of your template that prints out the URL in the field "link_test" with the label "Learn More." I put the "Learn More" text in the View itself as that'll be easier to edit and works better with the Link CCK type (which by default will want to add a title you add in the node edit screen).
The view export is here: http://pastebin.me/0ed2942f6953cb00cab1bd5386058a13. You can import this back into your site, but you may want to clone your original View first to make a backup, so that if this isn't what you want, you can use your old version.
The updated tpl is:
<div id="slider">
<div class="slider-holder">
<?php foreach($rows as $row): ?>
<div class="slide">
<?php print $row['field_image_fid'] ?>
<div class="info-slide">
<h2><?php print $row['title'] ?></h2>
<p><?php print strip_tags($row['teaser']) ?></p>
<?php print $row['field_link_test_url'] ?>
<?php //print_r($row); ?>
</div><!--INFO-SLIDE-->
</div><!--SLIDE-->
<?php endforeach ?>
</div><!--SLIDER-HOLDER-->
<div id="control">
</div>
</div><!--SLIDER-->
Let me know if you have any issues/questions.
Are you sure the template is getting picked up (add <p>heavymark</p> above the href... does it show up?)?
If above shows up, add a var_dump($node) above the anchor tag and post the output so we can get a better idea of what's there (you probably want to enable XDebug so you get better formatted output, if its not on already).
Make sure you add the link field to the view in the fields section. This should allow it to be themeable from within your template file. If you are still not seeing it, try using
print_r($rows,1);
or some variable of print_r to view all the rows that are available to be themed.
quick question I know in wordpress you can get post_content,etc
but let say I input into the content just a url such http://www.google.com and then
i want to get that url inside a div so it would look like something along those lines. do I have to do anything special with the url or can i simply just do get post_content.
My end goal is to incorporate the url in a colorbox so it will just grab the url from the post content and use it with the colorbox??
hope that made some sense...
thank you
-david
You do not have to do anything special in terms of preparing your post on the admin side, but to incorporate this into the Colorbox code, make sure you are putting the 'post_content' in the right place. In the 'Outside HTML (IFrame)' example from the Colorbox site:
http://colorpowered.com/colorbox/core/example1/index.html
You could implement your code as follows:
<?php your wordpress query here?>
<a class="colorboxClass" href="<?php the_content(); ?>">Your Colorbox Link Text</a>
<?php end your query?>