Javascript code will typically look something like this:
01 | jQuery(document).ready( function ($) { |
03 | $( '.gfield_checkbox input' ).click( function (){ |
04 | var is_checked = $( this ).is( ':checked' ); |
05 | var parent = $( this ).parent( 'li' ); |
08 | $(parent).addClass( 'selected' ); |
10 | $(parent).removeClass( 'selected' ); |
Some theme's will provide an init.js or, even better, a custom.js file. If so, pasting the custom Javascript in either of these files would be ideal. If neither is present, you can wrap your Javascript code in a script block and paste the code in your theme'sheader.php file below the wp_head() function call .
1 | script type= "text/javascript" |
2 | jQuery(document).ready( function ($) { |
PHP code will typically look something like this:
01 | function gform_add_post_format( $entry ) { |
03 | $post_id = rgar( $entry , 'post_id' ); |
08 | wp_set_object_terms( $post_id , 'chat' , 'post_format' ); |
PHP snippets will almost always be pasted in your theme's functions.php file. A few things to be aware of when adding PHP snippets.
- Your functions.php will already have an opening tag. If the snippet you are copying also has an opening PHP tag, be sure to remove it before pasting it into your functions.php file.
- If the PHP snippet you are copying has opening and closing PHP tags inside the code itself, do not remove these. This simply means that the code is exiting "PHP mode" to output content directly to the screen.
No comments:
Post a Comment