• Resolved neiljf

    (@neiljf)


    Hi there
    
    I want an ad to show below our logo, primary nav and breadcrumbs, but above the page title.
    
    I want it to show on our standard posts and standard pages. (I have included a link to one of those.) In our theme files, we have Single Post (single.php) and Single Page (page.php). We also have Theme Header (header.php).
    
    We have custom templates for other pages, and we have the home page, archive pages and author pages. I don't want it to show on those, which all have separate theme files.
    
    I've received a little advice as well as links to some help pages from Advanced Ads customer support, but I'm finding it just a little beyond me.
    
    The four things I'm trying to find out/solve/confirm are:
    
    1. I currently have the free version of Advanced Ads. Customer support tells me I can achieve what I want with the free version. Does that match your experience?
    
    2. What specific settings do I need to select in the Advanced Ads?
    
    3. What precise code do I insert, in which theme file(s), and where exactly do I insert the code (which row) in that file/those files?
    
    4. Do I need to insert the short code anywhere as well/instead?
    
    Regarding number three on that list, if it goes in header.php, the last few rows of our header are:
    
    ============================
    
    <?php //<div class="breadcrumb mb-5 lg:mb-16"> ?>
    
    <?php //} ?>
    
    <?php
    
    if ( function_exists('yoast_breadcrumb') ) {
    
    ?? yoast_breadcrumb( '<p id="breadcrumbs">','</p>' );
    
    }
    
    ?>
    
    <?php //if(function_exists('bcn_display')) { bcn_display(); } ?>
    
    </div>
    
    <?php } ?>
    
    <?php do_action( 'tailpress_content_start' ); ?>
    
    <main>
    
    ============================
    
    If it goes in single.php and page.php, the opening rows in single.php (page.php is very similar) are:
    
    ============================
    
    <?php get_header(); global $post;? ?>
    
    <div class="container mx-auto my-8 px-0">
    
    <div class="max-w-2xl mx-auto single_post_page">
    
    <h1 class="title-box ft-arvo text-4xl font-bold text-gray-900 leading-10 mb-4 lg:px-6"><?=get_the_title()?></h1>
    
    <?php if ( !in_category('Guides') ) { ?>
    
    ============================
    
    In case you need it, for my ad:
    
    The shortcode is [the_ad id="35670"]
    
    The template (PHP) code is <?php the_ad('35670'); ?>
    
    If it helps, I have assigned the ad to a group, although it's the only ad in the group.
    
    The ad is currently in draft.
    
    Thank you very much for any assistance!
    
    Neil

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support schmidt25

    (@schmidt25)

    Hi neiljf,

    Thanks for reaching out.

    I currently have the free version of Advanced Ads. Customer support tells me I can achieve what I want with the free version. Does that match your experience?

    You can realize what you describe with the free version of Advanced Ads. I hope our support sent you a link to our tutorial about embedding header ads into your website. This article describes several ways to inject ads into this position. For your task is the first method most relevant: “PHP function / Manual Placement”.

    What specific settings do I need to select in the Advanced Ads?

    Please, create a Manual placement. Give it a clear name, e.g., Header Ads.

    What precise code do I insert, in which theme file(s), and where exactly do I insert the code (which row) in that file/those files?

    You insert the PHP function for that placement. You can copy this code from your placement page and find more information in the abovementioned manual.

    Please, check your code again. It looks wrong. The PHP must look like this:

    <?php if( function_exists('the_ad_placement') ) { the_ad_placement('bcn_display'); }				?>

    It depends on your theme where you exactly need to embed this snippet. It might be possible that you need to edit several files, including the files for single posts, pages, and archive pages. The breadcrumbs can also give a good orientation if they are directly integrated into the theme files. I recommend creating a dummy ad, assigning this to a manual placement, and playing around with several positions for the PHP snippet in the code to find the perfect spot.

    This integration means a little work at first, but once you have found the correct position, you can quickly apply it to the other theme files. The good thing is you only have to do this once, and you are done.

    I hope this information helps you.

    Joachim

    Thread Starter neiljf

    (@neiljf)

    Thanks a lot for that, Joachim!

    You wrote that my PHP code looks wrong, so I presume I’m copying the wrong code.

    I got that code by clicking on the ad to edit it. There’s a “Usage” section, which contains the PHP code there.

    Am I looking in the wrong place?

    When you say “the PHP must look like this”, do you mean literally exactly as you did it, or am I supposed to replace part of that with e.g. the ad’s code (“35670”)? If so, can you show me exactly how to replace it?

    Thanks again,

    Neil

    Plugin Support schmidt25

    (@schmidt25)

    Hi Neil,

    The problem was that it looked like you replaced 'the_ad_placement' with the name of your placement. If you copy the content of the “template (PHP)” field after clicking the usage button, you will have the correct code.

    Best regards,

    Joachim

    Thread Starter neiljf

    (@neiljf)

    Hi Joachim

    There’s no usage button. The section Usage has a “Template (PHP)” field and I copied the entire code from there. I’ve double-checked and I haven’t accidentally clipped the code short.

    Am I looking in the wrong place? I’m in WordPress > edit Ad, and looking at the Usage section…

    I’ve done a screenshot of what I see and put it on this web page: https://www.4thway.co.uk/35681-2/

    Plugin Support schmidt25

    (@schmidt25)

    Hi Neil,

    Please, navigate to Advanced Ads > Placements, an scroll down to your manual placement. You will find a link (Show usage) in the first column.

    Best regards,

    Joachim

    Thread Starter neiljf

    (@neiljf)

    Hi Joachim

    Thanks for your help. I found it where you said it would be. But I still can’t get the ad to show.

    I published my ad, selected manual placement, and got a message that the ad was now visible in the front end.

    In WordPress > Advanced Ads > Placements, I clicked on Show Usage next to the manual placement and copied the code, which is:

    if( function_exists(‘the_ad_placement’) ) { the_ad_placement(‘above-title’); }

    I then pasted this beneath the top line in my Single Post (single.php) file. The top line was a php get header line. When I checked the website, instead of seeing the ad, I could see the code showing between the header and the page title.

    So I then moved the code to beneath the next row in Single Post and tried again. The same issue occurred.

    I kept trying this, moving the code down one line at a time until I reached the h1 get title row. Since I want the ad to appear above that, I didn’t try pasting it beneath that row.

    I then tried pasting it into the Theme Header (header.php) file instead. This time, I started at the bottom. I tried every row up to the breadcrumbs, which should appear above the ad.

    In each attempt, the code showed on my website instead of the ad.

    Have you – or has anyone – got any suggestions where I might be going wrong?

    Thanks very much,

    Neil

    • This reply was modified 1 year, 11 months ago by neiljf.
    Plugin Support schmidt25

    (@schmidt25)

    Hi Neil,

    Thanks for your reply.

    I guess that you just pasted the code and did not add the necessary PHP code before injecting this to your theme.

    Can you please use this code instead?

    <?php if( function_exists(‘the_ad_placement’) ) { the_ad_placement(‘above-title’); }				?>

    Best regards,

    Joachim

    Thread Starter neiljf

    (@neiljf)

    Thanks Joachim. Yes, I was missing that part of the code.

    I tried again, but I’m getting a different error when inserting into that full code into either Single Post or Theme Header now.

    The live site template breaks and the live site shows the error “There has been a critical error on this website.”

    You can see a screenshot of how it looked on the site here: https://www.4thway.co.uk/35681-2/

    Also on that page, you see an example of where I tried to paste it into the Single Post, with a couple of orange crosses showing alternative places tried.

    If you still have any patience left – or anyone else – please share your thoughts!

    Thank you very much once again,

    Neil

    Plugin Support schmidt25

    (@schmidt25)

    Hi Neil,

    Oh, I am so sorry. I used accidentally the wrong quotes. Can you please use the code below instead?

    <?php if( function_exists('the_ad_placement') ) { the_ad_placement('above-title'); }				?>

    Best regards,

    Joachim

    Thread Starter neiljf

    (@neiljf)

    Hi Joachim

    It’s working!

    Thank you very much!

    I really appreciate the time and effort you’ve taken for me.

    Best wishes,

    Neil

    • This reply was modified 1 year, 11 months ago by neiljf.
    Plugin Support schmidt25

    (@schmidt25)

    Hi Neil,

    I am glad to hear that you could figure out how to embed the manual placement at this position.

    Best regards,

    Joachim

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Getting ads to show above the title on standard pages and posts’ is closed to new replies.