Stikckymenu pentru wordpress

Plugin-uri, teme, configurare

Moderator: Moderatori

indexcafea
Average Member
Mesaje: 65
Membru din: Mie Noi 07, 2012 9:18 pm
Contact:

Stikckymenu pentru wordpress

Mesajde indexcafea » Dum Aug 04, 2013 11:58 am

Incerc sa fac un stickymenu pentru wordpress si nu inteleg de ce nu merge.

Am facut asa:

Functia care imi schimba css-ul cu position fixed:

Cod: Selectaţi tot

$(function() {
 
    // grab the initial top offset of the navigation
    var sticky_navigation_offset_top = $('#stickyheader').offset().top;
     
    // our function that decides weather the navigation bar should have fixed css position or not.
    var sticky_navigation = function(){
        var scroll_top = $(window).scrollTop(); // our current vertical position from the top
         
        // if we ve scrolled more than the navigation, change its position to fixed to stick to top,
        // otherwise change it back to relative
        if (scroll_top > sticky_navigation_offset_top) {
            $('#stickyheader').css({ 'position': 'fixed', 'top':0, 'left':0 });
        } else {
            $('#stickyheader').css({ 'position': 'relative' });
        }   
    };
     
    // run our function on load
    sticky_navigation();
     
    // and run it again every time you scroll
    $(window).scroll(function() {
         sticky_navigation();
    });
 
});


Apoi in function.php (tema) am inclus jquery-ul de mai sus:

Cod: Selectaţi tot

function wpse101288_enqueue_script() {
   wp_enqueue_script(
      'stickyheader',
      get_stylesheet_directory_uri() . '/js/stickyheader.js',
      array( 'jquery' )
   );
}

add_action( 'wp_enqueue_scripts', 'wpse101288_enqueue_script' );


M-am uitat in sursa paginii si pare sa fie inclus corect:

Cod: Selectaţi tot

<script type='text/javascript' src='http://popicul.ro/blog/wp-content/themes/twentyten/js/stickyheader.js?ver=3.5.1'></script>


Apoi in header.php am div-ul

Cod: Selectaţi tot

<div id="stickyheader">
          <div> aici este meniul </div>
</div>


Nu-mi dau seama unde e greseala :(



Înapoi la “Wordpress”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 25 vizitatori