WordPress.org

Ready to get started?Download WordPress

Forums

Promotion Slider
[resolved] Slider in hard code, need different slider on each page (7 posts)

  1. sberman
    Member
    Posted 2 years ago #

    Hi! I want the slider to be above the post/page content area, not inside it, so I hardcoded it into my php page template like this:

    <?php echo do_shortcode('[promoslider category="home" width="993px" height="235px"]'); ?>

    just above

    <div id="primary" class="subpage-alt">
    <div id="content" role="main">

    See: http://project.dmediaweb.com/akiba/

    Now it's in the correct place, but the slider is the same on every page. I need the slider to be different on every page. How do I do that?

    http://wordpress.org/extend/plugins/promotion-slider/

  2. Micah Wood
    Member
    Plugin Author

    Posted 2 years ago #

    You would have to use PHP to detect the current context of the page and pass a different shortcode to the do_shortcode() function.

    For example:

    if( is_home() ) {
        echo do_shortcode('[promoslider category="home" width="993px" height="235px"]');
    } else if ( is_page() ) {
        echo do_shortcode('[promoslider category="page" width="993px" height="235px"]');
    }

    The code above would show one slider for the blog page and another for regular pages. Beyond that, it wouldn't show at all. You would just create a 'home' and 'page' category and assign your desired promotions to each category.

  3. sberman
    Member
    Posted 2 years ago #

    Thank you. Would I place this inside my page Template.php file?

    And if I want different sliders on different pages, do I just create a category for each page? Or do I have to create a new Template.php for each page to use?

    Like this?

    if( is_home() ) {
    echo do_shortcode('[promoslider category="home" width="993px" height="235px"]');
    } else if ( is_welcome() ) {
    echo do_shortcode('[promoslider category="welcome" width="993px" height="235px"]');
    } else if ( is_events() ) {
    echo do_shortcode('[promoslider category="events" width="993px" height="235px"]');

    I am new to WordPress so please forgive my confusion.

  4. Micah Wood
    Member
    Plugin Author

    Posted 2 years ago #

    The template itself is only used in certain contexts. It would depend on where you want the code to appear, which template files are used and in which contexts.

    Here are two links that would hopefully make this a bit more clear:
    http://codex.wordpress.org/Conditional_Tags
    http://codex.wordpress.org/Template_Hierarchy

  5. sberman
    Member
    Posted 2 years ago #

    So instead of hard-coding the slider, if I go back to putting it on each page/post with [pomoslider] in the post area, it can be a different slider on each page. This is truly what I want.

    But if I do that, the slider is not in the correct location. I don't want it to be INSIDE a post, but above it. And I want it to be the width of the entire page, not the width of the post content area.

    Do you have any suggestions for making it work this way? I appreciate your help!

  6. Micah Wood
    Member
    Plugin Author

    Posted 2 years ago #

    Personally, I would probably place the code in the theme template files. Unfortunately, without knowing which theme / template files you have and exactly what the contexts are that you want to display the slider in, I can't really help out much with specifics.

  7. sberman
    Member
    Posted 2 years ago #

    I am using Twenty-Eleven with a child Theme where I created new style.css and subpage.php files.

    Per your suggestion I will try the Template route. Right now all my pages are using the same subpage.php Template file except for the Blog page. I'll just have to make a different Template for each page I guess.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic