• Ivan Jaquez

    (@ivan-jaquez)


    Hello guys. I’m using the wp-subdomains which is a plugin for WordPress that allows you to setup your main categories, pages and authors as subdomains. I need to display ads based on post categories. I’ve found a method for doing so HERE. I don’t know php and want to know how to edit the displayads.php file discussed in that post to make it work for subdomains instead of categories.

    This is the code from the displayads.php file:

    <?php
    $categories = get_the_category();
    $fileName = strtolower($categories[0]->cat_name) . ‘.html’;
    $filePath = dirname(__FILE__) . ‘/’ . $fileName;

    if (file_exists($filePath))
    {
    ?>
    <!–begin common ad header–>

    <div style=”border: 1px dotted; background-color: #EEFEEF; padding: 10px”>

    <!–end common ad header–>
    <?php include $filePath; ?>
    <!–begin common ad footer–>

    </div>

    <!–end common ad footer–>
    <?php
    }

    If you need more details please let me know and thanks in advance.

  • The topic ‘Show WordPress Ads Based On Subdomains’ is closed to new replies.