Jump to content

bgbs

Members
  • Posts

    114
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

bgbs's Achievements

Member

Member (2/5)

0

Reputation

  1. I have this javascript code that loads in the footer. I only need this javascript to load on a static home page, not on all other pages. <script type="text/javascript"> var banner = (function(){ $('.banner').unslider({ speed: 1000, // The speed to animate each slide (in milliseconds) delay: 999000, // The delay between slide animations (in milliseconds) complete: function() {}, // A function that gets called after every slide animation keys: false, // Enable keyboard (left, right) arrow shortcuts dots: false, // Display dot navigation fluid: true // Support responsive design. May break non-responsive designs }); $( '#nav li:has(ul)' ).doubleTapToGo(); }); </script> <script> jQuery(document).ready(function() { jQuery('.nav-toggle').click(function(){ //get collapse content selector var collapse_content_selector = jQuery(this).attr('href'); //make the collapse content to be shown or hide var toggle_switch = jQuery(this); jQuery(collapse_content_selector).toggle(function(){ if(jQuery(this).css('display')=='none'){ toggle_switch.html('View All Services');//change the button label to be 'Show' }else{ toggle_switch.html('Hide Services List');//change the button label to be 'Hide' } }); }); }); </script> <script> jQuery(document).ready(function() { jQuery('.navtop-toggle').click(function(){ //get collapse content selector var collapse_content_selector = jQuery(this).attr('href'); //make the collapse content to be shown or hide var toggle_switch = jQuery(this); jQuery(collapse_content_selector).toggle(function(){ if(jQuery(this).css('display')=='none'){ toggle_switch.html('Menu');//change the button label to be 'Show' }else{ toggle_switch.html('Hide Menu');//change the button label to be 'Hide' } }); }); }); </script> So far I have this php statement, but I'm having trouble wrapping it in this php code. <?php if ($page=="home") echo " "; ?> I'm not sure if putting the whole javascript code above is a good idea in the echo quotes. Is there an easier or better way of wrapping javascript in PHP? Your help appreciated.
  2. Ok, so Im using if else in WP <?php if ( is_home() ) { // This is a homepage } else { <!-- header image --> <div class="dynamic-header"><?php if(function_exists('show_media_header')){ show_media_header(); } ?></div> <!-- /header image --> } ?> What I'm trying to do is load dynamic header banner on other pages except for home page. But I know I can't call php within php, so how do I properly wrap the code after else statement? Thanks in advance
  3. You guys are an unbelievable support community. Thanks
  4. I have this code <?php if ( $page == "home" ) { echo '<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/expand.js"></script>';} ?> for $page, can I put several pages in the quotes where I currently list "home". If I can, how would I do this, because putting comma doesn't seem to work for me, although syntax error is not displayed. Thanks in advance
  5. Thanks a million, that answers it for me.
  6. I have a plugin that outputs username after login, I want it to display first name instead. Here is the code that does it. global $userdata,$user_identity; get_currentuserinfo(); if ($userdata->ID>0) { // User is logged in echo '<div class="login">' . $before_widget . $before_title . "Welcome ".$user_identity . $after_title . '</div>'; echo ' <ul class="login-links"> <li><a href="'.get_bloginfo('wpurl').'/wp-login.php?action=logout&redirect_to=http://'.$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI'].'">Logout</a></li> <li><a href="'.get_bloginfo('wpurl').'/wp-admin">Dashboard</a></li> <li><a href="'.get_bloginfo('wpurl').'/wp-admin/profile.php">Profile</a></li> </ul> '; } else { // User is NOT logged in!!! echo $before_widget . $before_title . '<div class="login">Welcome Guest, <a href="'.get_bloginfo('wpurl').'/wp-admin">Login</a></div>' . $after_title; $user_identity is what outputs that username. I searched through wordpress forums and someone said I have to add $current_user->first_name to the code. The question is, where and how do I add it? I assume I would need to add it to this line global $userdata,$user_identity; But how do I properly syntax that? I tried doing it myself like this global $userdata,$user_identity = $current_user->first_name; but I'm getting syntax errors Your help is highly appreciated.
  7. This way will not work because I'm already working within php. Another words the statement below is already contained in php brackets, so echoing php within php will not work. <?php case 'email': $html .= ' <input name="s" id="s" value="Email..." type="text" size="18" value="'.esc_html($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input"/>'; break; ?>
  8. Hi I have this input box wrapped in php code case 'email': $html .= ' <input name="s" id="s" value="Email..." type="text" size="18" value="'.esc_html($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input"/>'; break; And I would like to add this javascript into the input form onfocus="if (this.value == 'Search...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search...';} So, the newb that I am, I tried this and got a syntax error <input name="s" id="s" onfocus="'.if (this.value == 'Search...') {this.value = '';}.'" onblur="'.if (this.value == '') {this.value = 'Search...';}.'" value="Email..." type="text" size="18" value="'.esc_html($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input"/>'; Any ideas how to properly integrate this javascript code into PHP? Thanks in advance
  9. That worked! But wait, why did you have to break this to two separate echo statements? Why couldn't this be wrapped all in one echo? Thanks for your help Ben
  10. It is a huge php file with pages of code wrapped in php tags. And in between those tags, I'm just trying to add a statement to output an image from images folder, and instead of echoing full url path, I'm using the wordpresses path to template folder, and how to do this properly in echo is where I'm stock right now. But as I posted above here is what I've been able to do echo '<img src="'. bloginfo('template_directory') .'/images/image.png" title="" alt="" />'; But it outputs, when viewing html source, as: http://site.com/wp-content/themes/mytheme <img alt="" title="" src="/images/image.png">
  11. This will not work, because the whole echo statement needs to be wrapped in php tags. I just tried this and it is working half way echo '<img src="'. bloginfo('template_directory') .'/images/image.png" title="" alt="" />'; But it outputs, when viewing html source, as: http://site.com/wp-content/themes/mytheme <img alt="" title="" src="/images/image.png">
  12. You mean like this? <?php echo '<img src="bloginfo('template_directory')/images/image.png" title="" alt="" />'; ?> This doesnt work
  13. This is used by wordpress, but I know Im not properly wrapping it in echo statement
  14. I need to rewrite this php statement <img src="<?php bloginfo('template_directory'); ?>/images/mainimage.jpg" title="" alt="" /> When I try to do this <?php echo '<img src="<?php bloginfo('template_directory'); ?>/images/mainimage.jpg" title="" alt="" />' ; ?> It does not work, because I guess I've open and closed a php code inside php. How do I properly write this statement? Thanks Ben
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.