![]() |
Simple Wordpress / Php-code question. HELP
Hey guys.
My php skills are something around 8%, so I need a little help. In my theme, I want to add the following php code: Code:
if( function_exists('the_ad_placement') ) { the_ad_placement('placement_after_vote'); } Code:
$return .= "<div class='wp-hotornot-title'><h2>$header</h2></div>"; Code:
$return .= "<div class='wp-hotornot-title'>if( function_exists('the_ad_placement') ) { the_ad_placement('placement_after_vote'); }</div>"; The stuff before and after the edited line still works, so it does not mess everything up. But I don't know, why it's displayed as plain text. It's a php-file of a plugin I use, so of course, there is more code including php open and end snippet. Any help would be appreciated. |
$return .= "<div class='wp-hotornot-title'>";
if( function_exists('the_ad_placement') ) { $return .=the_ad_placement('placement_after_vote'); } $return .="</div>"; . |
Delete :)
|
Quote:
Note to myself: Buy sarettah a beer. |
Argh, did not work as expected.
Well, the code works, yeah, but it messes my layout up a little. Any chance to put the code Code:
if( function_exists('the_ad_placement') ) { the_ad_placement('placement_after_vote'); } |
Quote:
You can very easily put it inside of <h2> tags. You can do: $return .= "<div class='wp-hotornot-title'><h2>"; if( function_exists('the_ad_placement') ) { $return .=the_ad_placement('placement_after_vote'); } $return .="</h2></div>"; Or: $return .= "<div class='wp-hotornot-title'>"; if( function_exists('the_ad_placement') ) { $return .="<h2> . the_ad_placement('placement_after_vote') . "</h2>"; } $return .="</div>"; The first one, the h2 tags will always be there even if there is nothing inside of them. The second one the h2 tags will only be there when the ad placement is there. Probably does not matter at all but could depending on what other code you have going on in there. . |
Ooops. Had a mistake in there, left out a quote mark.
Or: $return .= "<div class='wp-hotornot-title'>"; if( function_exists('the_ad_placement') ) { $return .="<h2>" . the_ad_placement('placement_after_vote') . "</h2>"; } $return .="</div>"; That's right now. . |
All times are GMT -7. The time now is 01:08 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123