Put Current Post's URL in Blogger

get_post
setup_postdata custom post type
wordpress set current post
wp insert post
get_posts
wordpress post object
wp_insert_post example
wordpress get the post object

I want to put URL of the current post in a textarea on each post so I typed following code in the post editor (HTML mode):

<script type='text/javascript'>
  var postUrl = '<data:post.url/>';
  document.write('<textarea>');
  document.write(postUrl);
  document.write('</textarea>');
</script>

But what appeared was

<data:post.url/>

which is not replaced by the post URL.

The layout HTML contains following code:

<body expr:class='&quot;loading&quot; + data:blog.mobileClass'>

Since there are many custom Facebook/Twitter widgets ('like' button, etc) available, I think there must be some way to pass the value of data:post.url to target jscript, but my googling failed.

You could put this in your post:

<div id="mytextbox"></div>

Then edit your template by putting this code at the bottom before the </body> closing tag.

<script type='text/javascript'>
var d=document;
var mydiv = d.getElementById(&quot;mytextbox&quot;);
if (mydiv!=null)
{
mydiv.innerHTML = mydiv.innerHTML + &quot;<textarea>&quot;+&quot;<data:blog.url/>&quot;+&quot;</textarea>&quot;;
}
</script>

Blogger layout code <data:blog.url/> actually returns The URL of the current page, not the URL of the blog.

wp_insert_post() | Function, When your going through your loop add this: global $post; $post = get_post( $ID, OBJECT ); setup_postdata( $post ); //Do something wp_reset_postdata();. The HTTP methods POST and PUT aren't the HTTP equivalent of the CRUD's create and update. They both serve a different purpose. They both serve a different purpose. It's quite possible, valid and even preferred in some occasions, to use PUT to create resources, or use POST to update resources.

Obviously it's just treating 'data:post.url' as a string since it's surrounded by quotes, does this work?

<script type='text/javascript'>
  document.write('<textarea>' + data:post.url + '</textarea>');
</script>

Manually set global $post vars with an ID, in order to use template tags, You could put this in your post: <div id="mytextbox"></div>. Then edit your template by putting this code at the bottom before the </body>  The PUT Method PUT is used to send data to a server to create/update a resource. The difference between POST and PUT is that PUT requests are idempotent. That is, calling the same PUT request multiple times will always produce the same result.

Use check below script, which is working for me.

<script type='text/javascript'>
     var postUrl = '<data:post.url/>';
     document.write("<div class="fb-like" data-href='" + postUrl + "' data-layout="standard" data-action="recommend" data-show-faces="true" data-share="true"></div>");
</script>

Its give link of each post accordingly.

Put Current Post's URL in Blogger, We do know, however, that when they put Public Law 199 in, our volume especially the cube and I don't believe the facilities of our current post office will  POST vs PUT. POST and PUT are very similar in that they both send data to the server that the server will need to store somewhere. Technically speaking, you could use either for the Create or Update scenarios, and in fact this is rather common. The difference lies in the details. PUT is idempotent.

You really don't need javascript to do that. You only need to specify a value using expr:value like this:

<input type="text" expr:value='data:blog.url'/>

You can then style it however you want by using inline style like this:

    <input type="text" expr:value='data:blog.url' style='height:30px; width:100px;' />

To ensure that you have the link in the right place, you must inspect the elements of the blog page carefully and paste the code in the desired location.

Hope that helps.

Hearings, Reports and Prints of the House Committee on Post Office , goods, and are taken possession of by the government and put into a general-​order One of the most important postal reforms needed at the present time is a​  Mark the post as currently being edited by the current user. wp-admin/includes/post.php: _admin_notice_post_locked() Outputs the HTML for the notice to say that someone else is editing or has taken over editing of this post. wp-admin/includes/post.php: wp_create_post_autosave() Creates autosave data for the specified post from $_POST data.

Current Literature, Four police officers in San Jose, Calif., have been placed on administrative leave after an anonymous blog post accused retired and current  The profile post should give some biographical information about the person and links where users can find more about them. You can probably guess that you should put information on why you chose to write an article on this person, but also consider adding some facts that aren’t well known so that your post can stand apart from any other

4 San Jose Officers Put on Leave Amid Probe Into Racist Facebook , We recommend that a time limit for internal reviews should be put into statute. The time limit should be 20 days, as at present under the Code of Practice, with a​  The Washington Post World section provides information and analysis of breaking world news stories. In addition to our world news and video, Post World News offers discussions and blogs on major

Post-legislative scrutiny of the Freedom of Information Act 2000: , setup_postdata() lets you treat any bundle of posts the way you would Set $​post global variable to the current post object setup_postdata(  Read the latest news and breaking news for local, U.S. and world events on the New York Post.

Comments
  • this code wont work in widgets..blogger API mostly works on the default template...u putting this in template right?
  • No i'm planning to put the script in each post. Before that I tried document.write(document.url); but document.url is just the URL of the blog.
  • to the best of my knowledge,it wont work in posts...blogger tags work only and only in templates,not posts/widgets.
  • thanks but data:blog.url gives only blog URL, not the URL of each post
  • I tried the code in my blog and it returns blog post URL. For more information about Blogger Layout Elements read this: support.google.com/blogger/bin/… where it says "url: The URL of the current page.","homepageUrl: The homepage of the blog."
  • if I clicked the title of a post, then the URL get changed, and the textarea shows the correct (post-specific) URL. Then using data:blog.url is just the same as document.write(document.url)?
  • Yeah, it seems so. If you want to put URL of the posts in the home page, then you should use data:post.url but you will probably have to locate the piece of code in the template that loops through the posts
  • Can you be more specific? :)
  • This puts nothing to the output.