Discuss Anything: 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!
Page 1 of 1

Embedding Javascipt Into Wordpress Posts Rate Topic: -----

#1 User is offline   Nelson Blogs 

  • Member [Level 3]
  • PipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 96
  • Joined: 24-January 10
  • Gender:Male
  • myCENT:28.52
  • Current Mood: Current Mood: None Chosen

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.
0


Page 1 of 1

Other Replies To This Topic

#2 User is offline   BuffaloHelp 

  • Sterling Archer
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • View gallery
  • Group: Admin - The Official Guru
  • Posts: 4,074
  • Joined: 23-April 05
  • Gender:Male
  • myCENT:76.42
  • Current Mood: Current Mood: Inspired

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.
0

#3 User is offline   mahesh2k 

  • Trap Grand Marshal Member
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 1,810
  • Joined: 23-January 05
  • Gender:Male
  • Location:Valley of Darkness
  • myCENT:56.54
  • Spam Patrol
  • Current Mood: Current Mood: Tired

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.
0

#4 User is offline   Baniboy 

  • The one who lives in the chatroom
  • PipPipPipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 737
  • Joined: 03-November 08
  • Gender:Male
  • Location:/root
  • Interests:Everything...
  • My Role:a Spectator
  • myCENT:47.18
  • Current Mood: Current Mood: Bored

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).
0

#5 User is offline   Nelson Blogs 

  • Member [Level 3]
  • PipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 96
  • Joined: 24-January 10
  • Gender:Male
  • myCENT:28.52
  • Current Mood: Current Mood: None Chosen

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
0

#6 User is offline   linekill 

  • Super Member
  • PipPipPipPipPipPipPipPipPip
  • Group: Kontributors
  • Posts: 206
  • Joined: 16-July 07
  • Gender:Male
  • Location:Philippines
  • myCENT:67.88
  • Current Mood: Current Mood: None Chosen

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..
0

Share this topic:


Page 1 of 1


Similar Topics Collapse

  Topic Forum Started By Stats Last Post Info
Locked Topic Icon No Credit For Posts Questions & Queries sunkist 
  • 4 Replies
  • 1,502 Views
New Replies Icon Confused About Hosting Credits And Posts your Secret HideOut thugnature 
  • 5 Replies
  • 2,139 Views
Locked Topic Icon Question: A Reason To Staying Active
Why Trap17 host for posts?
Questions & Queries Microsoft 
  • 5 Replies
  • 1,043 Views
New Replies Icon Wordpress Question: Adding Static Text On The Theme
adding fixed text to the top of the main page
Website Discussion anwiii 
  • 4 Replies
  • 465 Views
New Replies Icon When Should I Use Quote Option On Forum Posts? Questions & Queries Misanthrope 
  • 2 Replies
  • 551 Views
Locked Topic Icon Negative Credits
Deleted posts etc...
your Secret HideOut outlawspirit 
  • 3 Replies
  • 1,741 Views
Locked Topic Icon Request Free Hosting
[no posts]
Free Web Hosting Account request crazydaredevil 
  • 15 Replies
  • 4,766 Views
New Replies Icon Php Safe Mode... On Or Off?
wordpress problems
Questions & Queries gummybear 
  • 1 Reply
  • 1,629 Views
New Replies Icon Wordpress 2.1.1 Found To Be Dangerous Computer Security Issues & Exploits rvalkass 
  • 4 Replies
  • 895 Views
New Replies Icon Wordpress Error Help Urgent Website Discussion gisellebebegirl 
  • 7 Replies
  • 579 Views
Locked Topic Icon Saint-Michaels Sigs Through the ages
Note*** i merge all my posts together***
Showoff Saint_Michael 
  • 69 Replies
  • 6,803 Views
Hot Topic (New) Icon Followup Of Netbux (yesterday's Posts Results) Make Money Online miCRoSCoPiC^eaRthLinG 
  • 16 Replies
  • 6,465 Views
New Replies Icon Wordpress Showing Designated Posts Website Discussion Little Asterisk 
  • 0 Replies
  • 143 Views
New Replies Icon Why Do Hosted Members Need Posts Aproved In The Internet Forum?
This is deeply annoying.
Suggestions shadowx 
  • 4 Replies
  • 616 Views
New Replies Icon Help With Wordpress Website Discussion Ash-Bash 
  • 5 Replies
  • 110 Views
New Replies Icon How Much Posts? Questions & Queries JackTheRipper 
  • 4 Replies
  • 838 Views
New Replies Icon T_string Error When Editing A Wordpress Theme PHP Programming arjpvc 
  • 1 Reply
  • 270 Views
New Replies Icon My Posts Got Deleted ! Questions & Queries ashiezai 
  • 6 Replies
  • 1,207 Views
Moved Topic No Credit For Posts your Secret HideOut Guest__* 
  • -1 Replies
  • 0 Views
  • Icon --
  • By: Guest__* 
New Replies Icon Wordpress Feeds
How to activate feeds
Web Design aka-2 
  • 6 Replies
  • 807 Views

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users


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