New answers tagged

0

You got javascript file and CSS file! Then you have to put those files in you child theme folder like themes -> your_child_theme_folder -> js(if you dont have js folder then create one) and place your js file here AND you have to put you css file in css folder inside your child theme. Now you need to call js file from functions.php If you dont ...


0

For editing content, I used the plugin Advanced Custom Fields. As for the conditionals, I just added if (is_page_template('template_name.php') before each wp_enqueue_script.


9

Each of the files you have mentioned are theme files. When you upgrade WordPress itself, it will not touch any themes (or plugins) you have installed, whether or not you have modified them. If this was a theme you created yourself, then you have no worries at all. However, if this was a theme created by someone else, for example a WordPress default theme, ...


0

Try using Autoptimize WordPress plugin or W3 Total Cache WordPress plugin, with W3 Total cache enable minify option. They both support combining and minifying all enqueued Scripts (JS) and Stylesheet (CSS)


0

Try This one : wp_register_script('cycleall', plugins_url('/assets/scripts/jquery.cycle.all.js', __FILE__), array('jquery'),'1.1', true); wp_enqueue_script('cycleall'); change script to scripts in add_action() should be add_action ('wp_enqueue_scripts', 'theme_add_cycle_slide' );


0

Problem was a simple misspelling. The add_action should be add_action ('wp_enqueue_scripts', 'theme_add_cycle_slide' ); I wrote 'script'


0

You don't need javascript, just change the class using the get_theme_mod variable e.g. <?php $layout = get_theme_mod('embee_layout_section_options[site_layout]', '3'); $class = ''; if($layout == '1') { $class = 'this'; } elseif($layout == '2') { $class = 'that'; } ?> <div class="<?php echo $class; ?>"> // stuff </div> Put that ...


0

Alternate Method The author of Metaslider suggests using WP Mobile Detect. Here is a sample of code I used to achieve a similar result to what I think you are looking for. Requires the WP Mobile Detect plugin. <?php if(shortcode_exists('metaslider') && function_exists(wpmd_is_notphone) && wpmd_is_notphone()): echo(...


0

You can pass a priority parameter to add_action. I don't actually know what priority Akismet has (default is 10), but you could start by trying this: add_action( 'wp_default_scripts', 'pwcc_jquery_to_footer', 9);


0

This kind of questions is better asked on StackOverflow community. Maybe this JS hack would help: var elem = document.querySelector('.search-form input[name="search_keywords"]'); if ( null !== elem ) { elem.onchange = function() { var e = this , v = e.value; if ( ! v ) return; v = v.toString(); if ( 0 === v....


0

FTP into your site and open up your wp-config.php file. Add this line: define('CONCATENATE_SCRIPTS', false); Make sure you add this before: /** Absolute path to the WordPress directory. */ if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/');


2

You can do something like this : // remove the script from the queue if were are on the post ID 11 add_action('wp_enqueue_scripts', 'remove_script_specific_post'); function remove_script_specific_post(){ if( 11==get_the_ID() ){ wp_dequeue_script('my_script_handle'); } } Provided that the script has been added with wp_enqueue_script


0

I got it solved.... function filter_image_send_to_editor($html, $id, $caption, $title, $align, $url, $size, $alt) { $animatedGif = (bool) get_post_meta($id, 'animated_gif', true); if($animatedGif){ $gifCoverImgUrl = get_post_meta( $id, 'animated_gif_cover_url', true ); // build my GIF player if(isset($gifCoverImgUrl) &&...


1

Please do not put this code into production OK. So there are many things wrong with the code that need fixing before we can even begin to answer your question. Firstly we're using $_REQUEST without good reason -- $_REQUEST gives us access to all of the information sent in the request, which means that $_POST['foo'] $_REQUEST['foo'] === $_GET['foo'] and ...


0

I can't comment on the validity of the AJAX call; it's a different style than I have used -- but inside the click(function(e) { code, you might try trapping the default page action to prevent it from triggering the page refresh: $("#myelement).click(function(e){ e.preventDefault();


0

If the javascript file is loaded from the admin dashboard, you can use this javascript function get the root of your WordPress installation. function getHomeUrl() { var href = window.location.href; var index = href.indexOf('/wp-admin'); var homeUrl = href.substring(0, index); return homeUrl; } Then just contact the path to your theme like below. ...


0

Kinda just answering this to counter the "not-possible" answers... Yes it is probably not the best thing to do, since we are still unsure what the OP is trying to achieve, but that does not make it not possible... complex and impractical perhaps, but still entirely possible. First enqueue the script as you normally would... here setting the minimum and/or ...


0

As @Mark Kaplan correctly points out, the right answer to this clear question is No. What you can do, and maybe asking on Stackoverflow will get a better answer, is run scripts in response to certain browser sizes and also detect when the window is resized if that is also important to you. This isn't without its problems, but these are JS issues, not WP ...


3

No it isn't. Server can not know browser width. Not sure it is even a smart idea since the width of the browser can change at any point.


1

I'm not sure why you are using exit() in yourreactivatejs()` method as this breaks the method before it even loads your script (hopefully this is for debugging purposes). I also do think that in is unnecessary to create a class to this, a simple spaghetti function would do perfectly. Anyways, if you need to use a class, the class's constructor is not ...


0

I found this approach to solve the problem of validate metabox fields using PHP code https://tommcfarlin.com/post-meta-data-error-messages/ Hope this help you (works for me in a similar scenario)


0

Ok so I finally managed to get it working, my map now displays, thanks to you people. What I did is : I changed the path to the absolute path of the scripts. Indeed, using a relative URL was a bad idea. I have changed my script, which now looks like that : document.addEventListener("DOMContentLoaded", function() { map_init(); }, false); var map; ...


1

If you had for example, <img src="rdp_banner.jpg" id="logoimage"> You could just do... add_action('init','checkvisitcookie'); function checkvisitcookie() { if (isset($_COOKIE['firsttimevisit'])) {return;} setCookie('firsttimevisit','1',100*365*24*60*60); add_action('wp_footer','fadelogoout'); } function fadelogoout() { echo "<...


1

You have wp_enqueue_script( 'showMake' ); twice. Remove the last line from your sdm_load_javascript_files function and see if it works.


0

If you're using SSL (HTTPS URL) you don't need to use oauth1.0 with oauth signature and everything. All you need to do is pass in the consumer_key and consumer_secret in the url https://localhost/wpShop/wc-api/v2/products?consumer_key=ck_1111111111122123&consumer_secret=cs_232332322233232 That's it! However, if your URL is NOT SSL, then you have to go ...


0

You need to use a combination of exception catching and a custom error handler. If you use this to suppress errors to the end user, you might want to add in some method that flags the error to the administrator/developer/yourself, so you are at least aware of the issue. Alternatively, instead of suppressing the errors, you could return an object with both ...



Top 50 recent answers are included