• I have several ads added as text in a widget.

    But I want to put one text ad within this block strictly on the home page.

    I’ve tried several solutions posted in these forums, but they also display the PHP code rather than just the ad.

    Suggestions?

    Peace,
    Gene

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi Gene. This google search returned a couple of plugins and some DIY solutions for running PHP code in a widget.

    Thread Starter genesteinberg

    (@genesteinberg)

    I’m halfway there. I found the Widget Logic plugin, and it works for the sites that have the ads in a widget.

    But I have another site where the ads are placed in fixed positions using an ad management plugin.

    I found this code that’s supposed to restrict content to the home page, but it won’t work:

    <?php if (is_home()) {
    ?>
    Ad text and link
    <?php
    }
    ?>

    Any other suggestions?

    Is that code from the ad management plugin? Do you add that code to the plugin somehow? Or is that supposed to go in the home page file? What’s the name of the plugin?

    Thread Starter genesteinberg

    (@genesteinberg)

    I added that code to the ad text. It came from one of the threads at WordPress on the subject of restricting this content to the home page.

    The ad plugin is Wp-Ad-Manager. It’s not being produced anymore, and I grant it may not be fully compatible with current WP versions, but with a tiny mod somewhere, it seems to be OK otherwise.

    Unfortunately, changing the ad manager isn’t always easy. I tried AdRotate, which has an importer for other ad plugins. I spent a while updating a version of my theme to change the ad placement code. But it is buggy, uses a tremendous amount of queries (about 125 for my site), and, on one of my sites, caches the wrong ads in the wrong positions. The developer has shown no interest in recognizing or fixing the problem.

    Peace,
    Gene

    it may not be fully compatible with current WP versions

    And it will only get worse as WP moves forward. One other option might be to use the theme Header Ads widget. You can enable that using Customizer > Header > Header Advertisement Widget. Then add a text widget with the ad code in Appearance > Widgets > Header Ads. Then, in Customizer > Dynamic Sidebars and Widgets > Create and manage widget zones > Header Ads, in the Context(s) box, remove all the contexts except Home; Save & Publish.

    Thread Starter genesteinberg

    (@genesteinberg)

    Your method sounds more complicated, however.

    I would love to move to a more modern ad management plugin, other than Ad Rotate (unless they take me seriously about the problems and fix them). Does anyone know of one that would allow for easy transfer/import from the current plugin?

    Peace,
    Gene

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Putting Widget Code on Home Page Only’ is closed to new replies.