GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech Simple Wordpress / Php-code question. HELP (https://gfy.com/showthread.php?t=1306460)

hausarzt 12-03-2018 06:37 AM

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'); }
This should appear in this div:
Code:

$return .= "<div class='wp-hotornot-title'><h2>$header</h2></div>";
As I dont need the h2-header, I tried this code:
Code:

$return .= "<div class='wp-hotornot-title'>if( function_exists('the_ad_placement') ) { the_ad_placement('placement_after_vote'); }</div>";
The result is, that the php code is displayed as plain text.
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.

sarettah 12-03-2018 08:04 AM

$return .= "<div class='wp-hotornot-title'>";

if( function_exists('the_ad_placement') )
{
$return .=the_ad_placement('placement_after_vote');
}

$return .="</div>";

.

TurboB 12-03-2018 09:50 AM

Delete :)

hausarzt 12-04-2018 01:58 AM

Quote:

Originally Posted by sarettah (Post 22375898)
$return .= "<div class='wp-hotornot-title'>";

if( function_exists('the_ad_placement') )
{
$return .=the_ad_placement('placement_after_vote');
}

$return .="</div>";

.


Note to myself:
Buy sarettah a beer.

hausarzt 12-05-2018 02:19 AM

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'); }
inside the <h2>-tag?

sarettah 12-09-2018 08:59 AM

Quote:

Originally Posted by hausarzt (Post 22377106)
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'); }
inside the <h2>-tag?

Hey, I must have missed this.

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.

.

sarettah 12-09-2018 11:35 AM

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