Can’t find variable is_single in my jQuery plugin

The easiest way in WP to write php into JS is using wp_footer function sse246626_js() { if(is_single()) { echo ‘<script type=”text/javascript”>’; echo ‘jQuery(document).ready(function($) {‘; echo ‘$(“#mydiv”).hide();’; echo ‘});’; echo ‘</script>’; } } add_action(‘wp_footer’, ‘sse246626_js’); This way gives you access to the WP functions as you need, there are probably better ways of doing it if … Read more

Can’t save custom post type fields

Try debug add_action(‘save_post’, ‘add_fields_contest’, 10, 2 ); function add_fields_contest( $id, $post ) { require_once(ABSPATH . ‘wp-includes/pluggable.php’); if ( $post->post_type == ‘contest’ ) { update_post_meta( $id, ‘userid’, $_POST[‘userid’] ); update_post_meta( $id, ‘title’, $_POST[‘title’] ); update_post_meta( $id, ‘name’, $_POST[‘name’] ); update_post_meta( $id, ‘age’, $_POST[‘age’] ); echo ‘Saving data to post id: ‘.$id; var_dump($_POST); die(); } I will … Read more

WordPress not displaying information on post sent from custom admin form

Your input needs to be saved somewhere, so it can be retrieved when a user visits the website. To achieve this you could for example use the update_option() and get_option() functions from the WordPress Options API to store the values. To store the value: function changeStyleFunction() { update_option( ‘newsSlide1’, test_input($_POST[“newsSlide1”]) ); } To retrieve the … Read more

Problem with baseurl and interaction with plugin

Most of the problem was resolved by pasting the following into my functions.php function my_init() { if (!is_admin()) { wp_deregister_script(‘jquery’); // Load the copy of jQuery that comes with WordPress // The last parameter set to TRUE states that it should be loaded // in the footer. wp_register_script(‘jquery’, ‘/wp-includes/js/jquery/jquery.js’, FALSE, ‘1.11.4’, TRUE); wp_enqueue_script(‘jquery’); } } … Read more

plugin modal/popup integration best practice

You should put it inside ‘the_content’ hook. 1)Create first plugin which has the form that proccess simple form submission. 2)And then call that page in iframe window.Like this: <—YOU DIV STARTS HERE FOR POPUP WINDOW–> <div id=”iframeclasses”> <?php add_thickbox(); ?> //Your form link <a href=”https://wordpress.stackexchange.com/questions/248296/YOUR_LINK_GOES_HERE&KeepThis=true&TB_iframe=true” class=”thickbox”> </div> 3)iframe window open by following code. <input type=”submit” … Read more

How to create a simple plugin which show/hide an html code in wordpress?

There is many ways to do it, create a shortcode to place anywhere you want or filter the post content and add what you want. If you plugin is not activate, this will not display, <?php /** * Plugin Name: Europhonica Image/Vidéo switch (by Jules) */ // the_content method add_filter( ‘the_content’, ‘image_my_switch_function_content’ ); function image_my_switch_function_content($content){ … Read more