How to add php within jquery

I see no reason for you to use PHP in your JavaScript file. Enqueue your script properly using the wp_enqueue_scripts hook and then use the wp_localize_script()function to pass your data to your JavaScript code. <?php function wpa67325_enqueue_scripts() { wp_enqueue_script( ‘some_handle’, ‘filename.js’, false ); $translation_array = array( ‘some_string’ => __( ‘Some string to translate’ ), ‘a_value’ … Read more

displaying the categories post

That happens because the_content() contains already an echo. PHP tries to create the string before it sends it to the echo command. While the string is evaluated the content will be printed already. Then echo gets what was not yet printed: the li tags. So the simple fix is: echo ‘<li>’; the_content(); echo ‘</li>’;

How to use wp_update_post with ajax on frontend

hmmm…. I don’t see a problem with your code. When I run into 500, it’s usually due to permissions or htaccess mis-routing the request. That said, some things to try: 1) in wp-config.php, set debug WP_DEBUG to true. This may offer a more descriptive error message. 2) WordPress has good integration for AJAX. You can … Read more

Dynamic WordPress editor in meta box

The problem is that the wp_editor() automatic load the scripts and this is not possible dynamic. You must enhance your plugin, code and add the scripts also dynamic or via ajax. WP include the scripts and styles via wp_enqueue_script() and this is not usable in a dynamic change of DOM, it was registered for better … Read more

JQuery Issues With WordPress Theme Interface

toscho…you were partly correct but helped immensely. Turns out the issue seems to lie within the theme’s attempt at calling up the scripts. My WP install is in a subfolder (/wp/) and it was looking for the wp-include scripts in the root folder. All other aspects of the site work fine, so I assume this … Read more

Cloning add_settings_field() with jQuery

jQuery can only clone what is on the current page or what is loaded over AJAX, so setting something up on the backend and cloning it on the front is not possible. What you can do is create a string and print to the front as a Javascript variable or as a hidden div that … Read more

Call javascript functions from each page

I would create a custom field containing the function to be called, for example called ‘function_to_call’. In the templatefile add the code $function_to_call = get_post_meta( get_the_ID(), ‘function_to_call’, true ); if ( $function_to_call != “” ) { echo ‘ jQuery(document).ready(function($){ ‘ . $function_to_call . ‘() }); ‘; } Doing this only outputs the function if you … Read more

JS Plugin not executing the js correctly. Trying to make all internal links scroll smoothly

Save your JavaScript code out to a separate file within your plugin directory. Then use this code to load the file using the wp_enqueue_script() function. function smooth_scrolling_links() { if ( !is_admin() ) { // Don’t load if in the admin screen wp_enqueue_script(‘Smooth-Scolling-Links’, plugin_dir_url(__FILE__) .’-YOURFILENAME-.js’); } } Obviously replace the -YOURFILENAME- with the file name that … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)