Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 15th Aug 2013, 03:59 AM   #1
HyperActive Warrior
 
Join Date: 2012
Posts: 117
Thanks: 67
Thanked 2 Times in 2 Posts
Default
How To Put JavaScript in Wordpress Posts?
Share on: 
fb share twitter share gplus share more share

Hello,

I want this chart to run on my wordpress website. Any suggestion would really help me.

Thanks
mirza786 is offline  
Unread 15th Aug 2013, 06:02 AM   #2
Code Painter
War Room Member
 
saxatwork's Avatar
 
Join Date: 2008
Location: Bangalore, India.
Posts: 124
Thanks: 152
Thanked 31 Times in 27 Posts
Default
Re: How To Put JavaScript in Wordpress Posts?
Share on: 
fb share twitter share gplus share more share

If you want to show only the chart in that page, why not use an iFrame instead of Javascript?

You can use this plugin - WordPress › iframe « WordPress Plugins - and add the iframe using a shortcode.

"Be Still Like A Mountain And Flow Like A Great River"
saxatwork is offline  
Unread 16th Aug 2013, 04:28 PM   #3
HyperActive Warrior
 
Join Date: 2012
Posts: 117
Thanks: 67
Thanked 2 Times in 2 Posts
Default
Re: How To Put JavaScript in Wordpress Posts?
Share on: 
fb share twitter share gplus share more share

Well I succeed in displaying Javascript graph in Gleam theme of Wordpress but seems like it is not support it because I tried changing to many other themes (including defaults one) and they are working nicely.....
mirza786 is offline  
Unread 16th Aug 2013, 06:00 PM   #4
WP Dev & Design
War Room Member
 
Join Date: 2011
Location: Earth
Posts: 787
Thanks: 92
Thanked 271 Times in 226 Posts
Blog Entries: 4
Default
Re: How To Put JavaScript in Wordpress Posts?
Share on: 
fb share twitter share gplus share more share

If you really want to use inline JavaScript like that graph link, you could use a plugin like Scripts-and-Styles which allows you to use inline JS, CSS on a per page/post basis so you don't have to load it except on the page needed.
David V is offline  
The Following 2 Users Say Thank You to David V For This Useful Post:
Unread 17th Aug 2013, 08:24 PM   #5
VIP Warrior
War Room Member
 
SteveJohnson's Avatar
 
Join Date: 2007
Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
Default
Re: How To Put JavaScript in Wordpress Posts?
Share on: 
fb share twitter share gplus share more share

OR - you could write yourself a simple WP shortcode handler that you can drop in your theme's function.php file. You could even make it into a plugin if you want so you can change themes.

Put this in theme's functions.php file, at the end (you should just remove the closing ?> tag if it's there):
PHP Code:
add_shortcode( 'mirzachart', 'mirzachart_shortcode');
function 
mirzachart_shortcode(){
  return 
'<script language="javascript" type="text/javascript" src="http://people.iola.dk/olau/flot/jquery.flot.js"></script>';
} 
Then just use the shortcode [mirzachart] in your post wherever you want to display the chart.
SteveJohnson is offline  
The Following 2 Users Say Thank You to SteveJohnson For This Useful Post:
Unread 19th Aug 2013, 01:56 AM   #6
HyperActive Warrior
 
Join Date: 2012
Posts: 117
Thanks: 67
Thanked 2 Times in 2 Posts
Default
Re: How To Put JavaScript in Wordpress Posts?
Share on: 
fb share twitter share gplus share more share

Originally Posted by SteveJohnson View Post

OR - you could write yourself a simple WP shortcode handler that you can drop in your theme's function.php file. You could even make it into a plugin if you want so you can change themes.

Put this in theme's functions.php file, at the end (you should just remove the closing ?> tag if it's there):
PHP Code:
add_shortcode( 'mirzachart', 'mirzachart_shortcode');
function 
mirzachart_shortcode(){
  return 
'<script language="javascript" type="text/javascript" src="http://people.iola.dk/olau/flot/jquery.flot.js"></script>';
} 
Then just use the shortcode [mirzachart] in your post wherever you want to display the chart.
Seems this is nice idea but it is not working for me. I did it according to the instructions. BTW what do u mean by removing ?> at the end? It is giving me error...
mirza786 is offline  
Closed Thread


Bookmarks

Tags
javascript, posts, put, wordpress


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 08:12 PM.