Discuss Anything: Replying To Embedding Javascipt Into Wordpress Posts - Discuss Anything

Jump to content


Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Replying to Embedding Javascipt Into Wordpress Posts

Enter a name

  • Security Code
    Your unique security code
    If you do not see any numbers, or see broken images, please contact a board administrator to rectify the problem.
    Confirm security code
    Please enter the 6 character code shown in the image. If you cannot read the code, click the image to generate a new one. Case sensitive.

    Can't make it out? Click here to generate a new image

Post

This post will need approval from a moderator before this post is shown.

Options

Post Options


Post icon

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •   [ Use None ]

  or Cancel


Topic Summary

linekill 

Posted 20 March 2010 - 11:25 AM

I'm not that familiar with WordPress but I did use it before.. If you want to embed a JS on a single post, why not create a copy of theme..say you have a Page.ph, copy it and create a Page2.ph and use it as a template of that single page where you want the JS to appear...and put the Javascript on the Page2.ph file..

This is the only answer I can think of so far...Will post for new idea..

Nelson Blogs 

Posted 22 February 2010 - 10:44 PM

Sorry for not being clear in my topic above. I need javascript in a single post, not all of them. I cannot put it in the footer or the header because then it would become site-wide. Thank you so much for your help

Baniboy 

Posted 21 February 2010 - 10:08 AM

You weren't very clear about this, so I'm going to assume you want to add a small piece of javascript to every post on your blog. In case that was what you meant (this can be used for loading comments with ajax for example or some other interactive function).

This depends on the theme you have. Try to find the php file(s) in your theme that load the posts(some themes have separate archive, single etc. files for loading). Now, what you do is you search for the loop that's used to get your posts. There should be php functions such as wp_posts(), x_storytitle(). Insert your javascript where you want it to be in a post and you can also modify the post content's displaying order a bit.

This is for embedded javascript. A much easier way to do this is view source in browser and search for the IDs of post elements in the post, then apply external javascript to those by getElementbyId in the .js file(s).

mahesh2k 

Posted 21 February 2010 - 06:40 AM

I think this is what you need to read : http://codex.wordpre...sing_Javascript

I've seen that java-script files are stored separately in js folder. That allows it is easy to organize if you've lot of code to put into. In documentation there is way mentioned how to add into template files or link external.

I hope the documentation link that is given in this post will answer most of your questions. If not, let me know what exactly you're trying for. I'll see with what i can help.

BuffaloHelp 

Posted 21 February 2010 - 06:23 AM

Are you trying to insert javascript on each post as it appears? Or, are you trying to insert javascript as a footer, header?

You can insert your javascript in item.php of your THEME, insert between anywhere you wish to attach.

You can insert your javascript header, head or footer files.

In your admin panel, you can add a custom box for any HTML codes (not tested with javascript from my end). Just go to Appearance > Widgets > and drag TEXT to the sidebar. Then, you can insert any HTML code which will be used on every sidebar.

Nelson Blogs 

Posted 21 February 2010 - 01:25 AM

I was wondering if there was any way to embed some javascript code into a WordPress post?  I try and put the code into my post but all that it does is display the code text.  I tried to look for a plugin but I had no luck finding one.

Review the complete topic (launches new window)


Google Fan :-) We Recommend Firefox.     Customize / Settings Connect Us on facebook