Simple Wordpress / Php-code question. HELP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hausarzt
    Confirmed User
    • Jan 2011
    • 818

    #1

    Tech 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
  • sarettah
    see you later, I'm gone
    • Oct 2002
    • 14298

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

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

    $return .="</div>";

    .
    All cookies cleared!

    Comment

    • TurboB
      Confirmed User
      • Dec 2016
      • 1059

      #3
      Delete

      Comment

      • hausarzt
        Confirmed User
        • Jan 2011
        • 818

        #4
        Originally posted by sarettah
        $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

        Comment

        • hausarzt
          Confirmed User
          • Jan 2011
          • 818

          #5
          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

          Comment

          • sarettah
            see you later, I'm gone
            • Oct 2002
            • 14298

            #6
            Originally posted by hausarzt
            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.

            .
            All cookies cleared!

            Comment

            • sarettah
              see you later, I'm gone
              • Oct 2002
              • 14298

              #7
              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 cookies cleared!

              Comment

              Working...