Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 12-03-2018, 06:37 AM   #1
hausarzt
Confirmed User
 
hausarzt's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: Somewhere in Germany
Posts: 815
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.
__________________
I know, my english is bad. But your german might be even worse
hausarzt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-03-2018, 08:04 AM   #2
sarettah
l8r
 
Industry Role:
Join Date: Oct 2002
Posts: 13,507
$return .= "<div class='wp-hotornot-title'>";

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

$return .="</div>";

.
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-03-2018, 09:50 AM   #3
TurboB
Confirmed User
 
TurboB's Avatar
 
Industry Role:
Join Date: Dec 2016
Posts: 960
Delete
TurboB is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-04-2018, 01:58 AM   #4
hausarzt
Confirmed User
 
hausarzt's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: Somewhere in Germany
Posts: 815
Quote:
Originally Posted by sarettah View Post
$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.
__________________
I know, my english is bad. But your german might be even worse
hausarzt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-05-2018, 02:19 AM   #5
hausarzt
Confirmed User
 
hausarzt's Avatar
 
Industry Role:
Join Date: Jan 2011
Location: Somewhere in Germany
Posts: 815
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?
__________________
I know, my english is bad. But your german might be even worse
hausarzt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-09-2018, 08:59 AM   #6
sarettah
l8r
 
Industry Role:
Join Date: Oct 2002
Posts: 13,507
Quote:
Originally Posted by hausarzt View Post
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 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-09-2018, 11:35 AM   #7
sarettah
l8r
 
Industry Role:
Join Date: Oct 2002
Posts: 13,507
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.

.
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
php, code, text, plain, displayed, $return, snippet, mess, appreciated, line, edited, php-file, plugin, including, theme, skills, php-code, wordpress, question, hey, guys, add, result, stuff, simple



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.