I want to display the products via shortcode IE: [product_category category="test" per_page="12"] In a carousel.
I have Flexslider setup, What I have tried is adding this to loop-start.php
<link rel="stylesheet" href="https://googledrive.com/host/0B4TRd-vaKaSkWUFRVkRiM1g2eGs" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="https://googledrive.com/host/0B4TRd-vaKaSkUHZIaTBXR0JLdVE"></script>
<script type="text/javascript" charset="utf-8">
$(window).load(function() {
$('.flexslider').flexslider({
selector : ".products > li",
animation : "slide",
controlsContainer : ".flex-container"
});
});
</script>
<div class="flexslider">
<ul class="products">
and closing the div after ul on loop-end.php
Though I'm not having any luck with it at all :/ It works on a test html file just fine.
The reason I want it like this and not just use some plugin is I have overlay popup that wont work with any Carousel plugin Ive tried and I also want to display multiple categories this way.
Thanks for any help
Initially I thought your markup didn't match, but then I saw that you've modified the loop. Though I think the jQuery selector ul.products would work. Because it should be container and its direct children as slides.
I would advise you to look in your browsers developer console to see what kind of script errors you are getting. But I suspect you are seeing something along the lines of function not defined since you aren't using no conflict wrappers. You have no idea how much this frustrated me in the beginning.
Your script should therefore look something like (though I think you should add it to the footer:
function so_28486348_print_footer(){ ?>
<script type="text/javascript" charset="utf-8">
jQuery(window).load(function() {
$('ul.products').flexslider({
selector : "li.product",
animation : "slide",
controlsContainer : ".flex-container"
});
});
</script>
<?php }
add_action( 'wp_print_footer_scripts', 'so_28486348_print_footer
I would also advise loading all your scripts (at least the external scripts) via wp_enqueue_script (see the codex link above)
function my_scripts_method() {
wp_enqueue_script(
'custom-script', 'https://googledrive.com/host/0B4TRd-vaKaSkUHZIaTBXR0JLdVE' ,
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
Related
i am calling a Header.php in main.php using
<head> </head>
<body>
<?php
include 'common/header.php';
?>
</body>
In the Head i am calling all the CSS and JS.
The CSS are being called in header.php properly.
In Header.php i have 2 tags. I would like to implement tooltip on one of them.
<li><a class="english" data-toggle="tooltip" title="Hooray!" href="">English</a></li>
also i added the JS for tooltip
<script type="text/javascript">
$(function() {
$('[data-toggle="tooltip"]').tooltip();
});
</script>
I tried to add this above code in header.php , bottom of index.php and also in head of index.php.
If i try to create a tooltip in the main.php file , it works absolutely fine.
there are no errors in console. I dont know what is the error.
Help ! TIA.
Try adding the code (script tag) at the bottom of header.php file, after all the html elements.
I'm having a div layer which should be moved to the right or left and when its moved far enough I want it to run a php statement ( Div 500px to right activates $state = 1;)
This is what I got so far:
<script>
$(document).ready(function () {
$('.swipe').draggable({
axis :'x', revert:true, revertDuration:'250',
});
});
</script>
This is my Div:
<div id="middleLayerShadow" class="swipe">... some stuff (pics and so on)...</div>
and the head part of the website:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="javascript/jquery-ui-1.12.1/jquery-ui.js"></script>
<link href="javascript/jquery-ui-1.12.1/jquery-ui.css" rel="stylesheet" type="text/css">
I want the div to go back like I programmed it with (revert:true) and when its dragged and drop at a far enough distance to left or to right i want it to disappear and somehow let a variable in php register it :)
Imagine it like a Tinder rating field where you swipe left and right!
Please help ! :)
my problem is quite annoying and weird. I have created a custom Wordpress theme and in the header.php I was loading jquery like this (can't remember why right now):
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript"> google.load("jquery", "1"); </script>
Last night I replaced the code above with
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
and then my site collapsed. I changed it immediately back again, but the problem persisted. I placed some Jquery in the HTML and it works just fine. Then I disabled my plugins by commenting out code in my functions.php file as below:
<?php
if (!is_admin()) {
wp_register_script('custom', get_stylesheet_directory_uri().'/js/custom.js');
wp_enqueue_script('custom');
wp_register_script('blockui',get_stylesheet_directory_uri().'/js/jquery.blockUI.js');
wp_enqueue_script('blockui');
wp_register_script('fancy',get_stylesheet_directory_uri().'/js/jquery.fancybox.js');
wp_enqueue_script('fancy');
wp_register_script('jeasing',get_stylesheet_directory_uri().'/js/jquery.easing.js');
wp_enqueue_script('jeasing');
wp_register_script('friendchooser',get_stylesheet_directory_uri().'/js/jquery.friendChooser.js');
wp_enqueue_script('friendchooser');
wp_register_script('zclip', get_stylesheet_directory_uri().'/js/jquery.zclip.min.js');
wp_enqueue_script('zclip');
}
?>
Still the problem occurs. Any ideas?
There is syntax error in custom.js file in line 30. Just remove } from there.
And learn some about firebug, it's very helpful :)
I have this anchor link in my index.php:
<a name="blog"></a>
I would like this anchor link to work When next_posts_link and previous_posts_link are clicked on so it doesn't go all the way to the top of the page. I have no idea how to go about doing this for WordPress pagination though.
Here is my code for the pagination:
<div class="pagenavi">
<?php if( function_exists( 'wp_pagenavi ' ) ) {
wp_pagenavi();
} else {
next_posts_link ('<div class="arrow-back"></div>'); }
previous_posts_link('<div class="arrow-forward"></div>') ; }
Solution 2:
Adding anchor tag #blog to the prev/next links in a blogpost using jQuery
<script type="text/javascript">
$(document).ready(function() {
$('.pagenavi a').each(function(i,a){$(a).attr('href',$(a).attr('href')+'#blog')});
});
</script>
Demo:
http://jsfiddle.net/mfeldheim/EkMfP/12/
unfortunately the wp_pagenavi function seems to encapsulate the complete link building.
If you can't configure a generic postfix in your wordpress or plugin configuration I don't recommend to change Wordpress code.
Instead you could execute a small JavaScript which moves the browser page to the anchor on load.
This example uses jQuery. Paste it into a bottom location of your template.
<script type="text/javascript">
$(document).ready(function() {
$('html, body').scrollTop(
$('[name="blog"]').offset().top
);
});
</script>
Couldn't test this but should work. Even simple scripts are the hell to write on a iPhone keyboard..
EDIT:
Works like a charm, check this out for a demo
http://jsfiddle.net/mfeldheim/EkMfP/7/
I would like to apologize at first instant for asking some stupid question(well not the case for me), but i cannot help it out. i must admit i do not know jQuery but i do have the basic understanding of Javascript and i am a dedicated PHP developer. i don't have any problem understanding the HTML or css. when it comes to jquery i lag it and i dont have enough time to learn it because of the deadline i have to meet.
to start with i developed an application using php and purchased a template from themeforest, now it has some nice and beautiful javascript code the problem is i do not know how to make it work. even though it lies right infront of me. here is my code in the login page. where i want to use this jquery
<link rel="stylesheet" type="text/css" href="css/basicblack.css" title="styles5" media="screen" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/supersleight.js"></script>
<script type="text/javascript" src="js/jquery.example.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/styleswitch.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready(function(){
$(".block").fadeIn(1000);
$(".msg-error").fadeIn(1000);
$(".msg-warning").fadeIn(1000);
$('.msg-error').supersleight();
$('#username').example('Username');
$('#password').example('Password');
});
/* ]]> */
</script>
and now i want to use the fadein effects for the class msg-error and msg-warning in my code, it is not working, here is the combined code with PHP logic which i have used.
although with this i am able to get the desired result like it will show the error if the field is empty or invlalid username and password. but i am unable to use that fadein effect. how do i do that?
<div id="wrap">
<?php if(isset($_POST['login'])) { if( empty($_POST['username']) || empty($_POST['password'])) { ?>
<div class="msg-error">
<img src="images/icons/22/messagebox_warning.png" alt=""/>
<p>Please fill in all of the fields!</p>
</div>
<?php } }?>
<?php
if( isset($_POST['login'])) {
if( !empty($_POST['username']) || $_POST['password']) {
if( !check_login($_POST['username'], $_POST['password'])) {
?>
<div class="msg-error">
<img src="images/icons/22/remove.png" alt=""/>
<p>Wrong username or password!</p>
</div>
<?php } } } ?>
As grossvogel suggests, it is likely that the elements are not hidden to begin with. Bear in mind that if you hide them with CSS, they will be less accessible to users without JavaScript. You could do something like this instead:
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready(function(){
$(".block").hide().fadeIn(1000);
$(".msg-error").hide().fadeIn(1000);
$(".msg-warning").hide().fadeIn(1000);
$('.msg-error').supersleight();
$('#username').example('Username');
$('#password').example('Password');
});
/* ]]> */
</script>
This type of approach is known as progressive enhancement.
My guess is that these items are not fading-in because they're visible to start with. Use simple CSS (display:none) to hide them, then the jquery fadeIn calls should display them once the page is loaded.
update
As others have pointed out, it's probably better to hide the messages with js instead of css, to allow users withough javascript to see the messages.
I'm just guessing here, but the problem might be that, given what I can see here, your "msg-error" divs are already displayed, so they can't be faded in. Try modifying your jQuery like so:
$(document).ready(function(){
$(".block").hide().fadeIn(1000);
$(".msg-error").hide().fadeIn(1000);
$(".msg-warning").hide().fadeIn(1000);
$('.msg-error').supersleight();
$('#username').example('Username');
$('#password').example('Password');
});
You can change these three calls:
$(".block").fadeIn(1000);
$(".msg-error").fadeIn(1000);
$(".msg-warning").fadeIn(1000);
To just this:
$(".block, .msg-error, .msg-warning").hide().fadeIn(1000);
This uses the multiple selector to get all 3 at once, and does a .hide() to hide them just before fading them in. The benefit of this is that if a user has JS disabled, they'll still get the errors, just without a fade.