• davy_yg

    (@davy_yg)


    Hi, all –

    I have a dillema that I would like to ask:

    My about subpages:

    About

    Only works if I turn off:

    wp_enqueue_script(‘slideshow_script’); function. (in localhost)

    It still does not work live. Why ?

    The dillema is I need that function for the front page or home if I turn it off then, the front slideshow will not works. Any body has any solution how to keep the slideshow works without meshing up the about subpages (in localhost) ?

    Anyone has other solution ?

Viewing 15 replies - 1 through 15 (of 17 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    This doesn’t sound like a multisite specific issue.

    Is that function from a plugin or a theme?

    Thread Starter davy_yg

    (@davy_yg)

    It’s a theme. function.php I add the Javascript codes link in the functions.php.

    you can check the source if you would like:

    About – Vision

    Last time you said I must turn off the slideshow script. I did and it works only in localhost. It doesn’t work online.

    Thread Starter davy_yg

    (@davy_yg)

    I also only able to see the real custom page offline if I login to admin page at the same time, otherwise this type of page appears:

    About – Vision

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    You need a different theme, man. That one’s messed up all over the place.

    Turn on the DEFAULT TwentyEleven theme, and turn off ALL plugins on that site.

    Thread Starter davy_yg

    (@davy_yg)

    I have no choice. I have to fix the sub-pages on that themes. I am developing it for someone.

    You mean switching the themes temporarily and slashing out all the plugin from functions.php ?

    Well, here is a similar thread: custom page that might give better prespective on the problem.

    Thread Starter davy_yg

    (@davy_yg)

    Strange, I have tried turning off all the JS link from functions.php . and the same page is still appears.

    <link rel="stylesheet" type="text/css" media="screen" href="sidebanner.css" />
    <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="js/jquery.cycle.all.js"></script>
    <script type="text/javascript">
    
    $(function() {
    	$('#slideshow').before('<div id="nav" class="nav">').cycle({
    	fx:     'fade',
    	speed:  'fast',
    	timeout: 3000,
    	pager:  '#nav',
    	before: function() {
    	if (window.console) console.log(this.src); }
    });
    });
    <HTML>

    I wonder where all those things come from ? I already turn of all the js from functions.php

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Switch to a different theme to TEST if it’s the theme.

    Thread Starter davy_yg

    (@davy_yg)

    Well, I can’t test it in different themes.

    For example: if I switch to TwentyEleven theme for example. The side navigation will disappeared.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    You can test, you just don’t want to. Different things. The side navigation will be saved, buy the way. But if you don’t test, you will never know if it’s your theme or a rogue plugin.

    You know what you need to do. Go do it.

    Thread Starter davy_yg

    (@davy_yg)

    what’s a rogue plugin?

    Well, the side navigation is a custom side navigation from the theme that I developed. Other’s themes do not show the custom navigation if I switch the themes only the content.

    The side custom navigation directs me to custom sub pages.

    Probably the theme, and then how to fix the custom themes?

    About

    I already try to disable the whole JS from functions.php and

    About – Vision

    Still shows me incorrect page.

    Last time, you told me because there is some script above the html. I do not know how to erase them.

    Thread Starter davy_yg

    (@davy_yg)

    Hi,

    I copy some files like about, about – vision, page.php to twentyten theme and it works.

    The side navigation direct to the about – vision page correctly.

    That’s correct, the <!DOCTYPE html> suppose to on top and all the link to JS and css underneath it.

    Why there are some script above <!DOCTYPE html> on my custom theme ?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    A rogue plugin is one that’s doing something stupid.

    However if your template works in another theme, with all the same plugins installed, congratulations! You have a broken theme!

    Moving this to the theme section.

    Chip Bennett

    (@chipbennett)

    What is the slideshow script being enqueued, where (and exactly how) are you calling wp_enqueue_script('slideshow_script'); in functions.php, and how and where do you intend this script to be used in the template?

    Thread Starter davy_yg

    (@davy_yg)

    I call wp_enqueue_script(‘slideshow_script’); in :
    function my_scripts_method(){

    // for front page
    wp_register_script(‘jquery17_script’, get_template_directory_uri().’/js/jquery-1.7.1.min.js’, array(‘jquery’), ‘1.0’);
    wp_register_script(‘Cycle_script’, get_template_directory_uri().’/js/jquery.cycle.all.js’, array(‘jquery’), ‘1.0’);
    wp_register_script(‘slideshow_script’, get_template_directory_uri().’/js/slideshow.js’, array(‘jquery’), ‘1.0’);

    wp_enqueue_script(‘jquery17_script’);
    wp_enqueue_script(‘Cycle_script’);
    wp_enqueue_script(‘slideshow_script’);

    }
    add_action(‘wp_enqueue_scripts’, ‘my_scripts_method’);

    I intend the script to be used in home or frontpage.

    Chip Bennett

    (@chipbennett)

    This is very likely a problem:

    wp_register_script('jquery17_script', get_template_directory_uri().'/js/jquery-1.7.1.min.js', array('jquery'), '1.0');

    You’re enqueueing your own version of jQuery, instead of using the WordPress core-bundled version. To compound the issue, you’re making the core-bundled version of jQuery a dependency, which means that you’re automatically enqueueing both libraries.

    That becomes further problematic, here:

    wp_register_script('Cycle_script', get_template_directory_uri().'/js/jquery.cycle.all.js', array('jquery'), '1.0');
    wp_register_script('slideshow_script', get_template_directory_uri().'/js/slideshow.js', array('jquery'), '1.0');

    You enqueue your own jQuery version, and then make the core-bundled version the dependency for your other scripts.

    So, I would recommend that you change your entire function like so:

    function my_scripts_method(){
        // for front page
        wp_enqueue_script( 'jquery17' );
        wp_enqueue_script( 'Cycle_script', get_template_directory_uri().'/js/jquery.cycle.all.js', array('jquery'), '1.0' );
        wp_enqueue_script( 'slideshow_script', get_template_directory_uri().'/js/slideshow.js', array('jquery'), '1.0' );
    }
    add_action( 'wp_enqueue_scripts', 'my_scripts_method' );

    (No need to split the register and enqueue, since you’re doing both at the same time anyway.)

    That might fix your entire slideshow problem. If not, there will be something else we need to track down.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘function dillema’ is closed to new replies.