bgbs
-
Posts
114 -
Joined
-
Last visited
Posts posted by bgbs
-
-
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
-
You guys are an unbelievable support community.
Thanks
-
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
-
Thanks a million, that answers it for me.
-
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.
-
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; ?>
-
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
-
function
bloginfo('template_directory')
doesn't return but echoes value so there's no need to include it in echo!
I see
I appreciate your help.
-
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
-
Could you post entire php file or at least while function or class please?
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">
-
what about this?
<?php echo '<img src="'; bloginfo('template_directory'); ?>/images/mainimage.jpg" title="" alt="" />'
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">
-
Your are already writing in php so why are you opening another php block? try removing the <?php & ?> in the middle of your code!
You mean like this?
<?php echo '<img src="bloginfo('template_directory')/images/image.png" title="" alt="" />'; ?>
This doesnt work
-
This is used by wordpress, but I know Im not properly wrapping it in echo statement
-
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
-
How do I correctly display image?
<div class="nav-right"><?php next_posts_link('<img src="images/more-but.png" />') ?></div>
I must be writing it incorrectly.
Thanks in advance
-
Yes, removing extra closing fixed it. Thanks guys
-
<h3><a href="<?php echo $permalink; ?>" title="< ?php echo $parent_title; ?>"><?php echo $parent_title; ?></a></h3>
<?php } else { ?>
<h3><a href="<?php echo get_permalink(); ?>" title="< ?php echo $parent_title; ?>"><?php the_title(); ?></a></h3>
yes I do.
I corrected it, but I'm still seeing the same syntax problem
noticed the space between < ang ?php ?
-
Dreamweaver is telling me there is a syntax error right below the </ul></div> menu
<?php }
I know this is happening because I'm doing something with the header title located between <h3></h3>
Full code below, please help
<div id="sidebar"> <?php if($post->post_parent) $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0"); else $children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0"); if ($children) { ?> <div class="small_box widget_pages"> <h3><a href="<?php echo $permalink; ?>" title="< ?php echo $parent_title; ?>"><?php echo $parent_title; ?></a></h3> <?php } else { ?> <h3><a href="<?php echo get_permalink(); ?>" title="< ?php echo $parent_title; ?>"><?php the_title(); ?></a></h3> <?php } ?> <ul> <?php echo $children; ?> </ul> </div> <?php } if (is_page()){ #sidebar used for pages if (function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar Pages') ) : kriesi_small_description($themeurl); else: ?> <?php kriesi_small_description($themeurl); kriesi_small_description2($themeurl); ?> <div class="widget"> <?php /*?> <?php get_search_form(); ?><?php */?> </div> <?php endif; }else{ #sidebar used for blog & archives (category, tag, date, etc) if (function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar Blog') ) : kriesi_small_description($themeurl); else: ?> <?php kriesi_small_description($themeurl); kriesi_small_description3($themeurl); kriesi_small_description2($themeurl); ?> <div class="widget small_box"> <?php get_search_form(); ?> </div> <?php endif; } if (function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar Everywhere') ) : endif;?> </div><!-- end sidebar -->
-
I wonder if there is a php character recognition software out there that can be integrated into a site.
I have a site where I import loads amount of emails through an automated processes. The emails then get posted on the website. The problem is, some emails contain a big image ad as part of the body so the text becomes unsearchable because it is contained in the image. So I'm in need of a software that could read the text in the image that can also be displayed in the email or applied to keyword tags. Is there a PHP OCR software out there?
-
I was thinking in the beginning to store values in the php file for now, and then upgrade to the database later. I'm very new to php and I dont want to go over my head with this php construction. I'm trying to take it one step at a time to master php capabilities.
Thanks
-
my header file contains the <head> but I would like to have different meta tags displayed depending on the page being displayed. I know you could insert <head> into each file and be done with it, but that may drive me nuts as the site grows. So I'm trying to see how I can do it differently
So far I can do this with php
<?php $meta_title="Site title goes here"; $meta_heading="Site heading info goes here"; $meta_desc="Site Description goes here"; $meta_keys="Site, Key, Words, Go, Here"; ?>
Then I can call that meta tag by inserting this in the pages
<meta name="description" content="<?php echo $meta_desc ?>" />
I also have
$page=" unique page name"
inserted in each page.
I know this php meta script is incomplete, but what can I do to take it to the next level? Do I need to use and if statements, and how would I?
Thanks for all your help
-Ben
-
My advice is to find a simple script that uses Mysql and just tinker with it. Thats how I learned. It's pretty simple after you get the hang of it.
Sounds like a plan, do you know any good simple ones?
Thanks
-
Hi, I never done something like this, therefore I'm looking for some information, maybe a tutorial how to create a simple store and retrieve database script.
Basically I would need to design a form to store content into database. I need to store simple content -- category, title, description, and author. I would need to create database tables, and retrieve that data.
Any help on this subject is appreciative.
Thanks
-
Cool, thanks man.
Wrap javascript in php if statement
in PHP Coding Help
Posted
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.
So far I have this php statement, but I'm having trouble wrapping it in this php code.
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.