Forums

Custom sidebar content for each post page. (5 posts)

  1. marcov
    Member
    Posted 3 years ago #

    Hi,

    Being fairly new to wordpress I have been serching the forum and the knowledge base for two days. I have learned a lot but I have not found a solution to my problem, so now I am posting hoping someone can help.

    I use wp to promote software. I need to find a way to have any one post page show the corrispondent ads (image-banner text etc.) in the sidebars.

    Is there a plugin for this situation or I need to hack into the code and hope I don't mess it up?

    Thanks
    Marco

    PS
    If no plugin is available what can I do to find a solution? Thanks.

  2. Roger Theriault
    Member
    Posted 3 years ago #

    Try this... the wp-adserve plugin allows you to define "zones" as text strings. You can assign ads to specific zones.

    In your page.php template, in the sidebar, insert

    <?php AdServe("sw-zone-id" . $post->ID); ?>

    And then assign the ad(s) you need to zone sw-zone-idnn where nn is the Page id of your page.

    (You can do the same thing for category ids on the post side of things)

  3. marcov
    Member
    Posted 3 years ago #

    Thank you Roger.

    I got the plugin installed and activated and I am able to create ads with no problems as far as the plugin functionality goes but I must have misunderstood how to apply the snippet of php code.

    Let me try to be specific.

    In your page.php template, in the sidebar, insert

    <?php AdServe("sw-zone-id" . $post->ID); ?>

    I am using a theme called "i3theme". The code of the document page.php has only one line which calls the sidebar (just before the footer, at the very bottom), here is the whole code for page.php:

    <?php get_header(); ?>
      <div id="content">
    
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
        <div class="post" id="post-<?php the_ID(); ?>">
            <h1><?php the_title(); ?></h1>
    
    		<div class="entry">
    		<?php the_content('<p>Continue reading &raquo;</p>'); ?>
    		<?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
    		<?php edit_post_link('Edit', '<p>', '</p>'); ?>
    		</div><!--/entry -->
    
    	</div><!--/post -->
    
    		<?php endwhile; endif; ?>
    
      </div><!--/content -->
    
      <div id="footer">
    	  <a href="http://www.ndesign-studio.com/resources/wp-themes/">WP Theme</a> &amp; <a href="http://www.ndesign-studio.com/stock-icons/">Icons</a> by <a href="http://www.ndesign-studio.com">N.Design Studio</a>
    	  <span id="mangoorange">, columnized by <a href="http://www.mangoorange.com/">MangoOrange</a></span>
    	  </div>
    </div><!--/left-col -->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    I don't know how you call this type of programming expression. It looks to me as if it is going to retrieve the actual code for the sidebar from somewhere else. Anyway the point is that I don't know where to insert your suggested line of code.

    Since I can not see a way to insert your suggested code in this page.php document I thought that maybe I could have used the same code in the actual sidebar.php document. So that is what I did and this is what the last few lines of the document look like:

    <!--sidebox end -->
    
    	   <div id="links" class="dbx-box">
    
            <div class="sidebar_header"><div class="dbx-handle"><?php _e('Sponsor'); ?></div></div>
            <div class="dbx-content">
              <ul>
                <?php AdServe("sw-zone-id" . $post->ID); ?>
              </ul>
            </div>
          </div>
    
      <?php endif; ?>
    
    </div><!--/sidebar -->

    Then you say:

    And then assign the ad(s) you need to zone sw-zone-idnn where nn is the Page id of your page.

    As pages ID I use the post title for SEO reasons, therefore the URL for the page that I am testing is http://www.digitaleramarketing.info/identity-theft/identity-theft-prevention/ , so I gave the ad a zone name of sw-zone-ididentity-theft-prevention

    Well by looking at all this you probably already know why the ad does not show up in the post page sidebar (or any other page for that matter).

    Deeply appreciating any help you can give me. It is very critical to my project to be able to combine each post with the sidebar ads pertinent to the specifics of the post.

    Thank you very much.
    Marco

  4. Roger Theriault
    Member
    Posted 3 years ago #

    I meant insert the code in the sidebar, wherever that is...

    You need the numeric id ($post->ID) of the post, which is hidden behind the scenes by WordPress 2.5 unfortunately. However, when you edit that page using the editor, the page id will be in the URL (eg: 128 in this case):

    http://yourblog.com/wp-admin/page.php?action=edit&post=128

    So you'd make the zone sw-zone-id128 in the AdServe control panel.

  5. Tommie Hansen
    Member
    Posted 3 years ago #

    The call to the sidebar usually refers to sidebar.php if nothing else is defined in functions.php (in your themes folder).

    You can also call different sidebars in index.php, page.php, single.php, archives.php etc.. by simply register more sidebars (in your functions.php) - search for "sidebars" and "more sidebars" or whatever on these forums.

    --
    Regards,
    Tommie Hansen

Topic Closed

This topic has been closed to new replies.

About this Topic