WordPress.org

Ready to get started?Download WordPress

Forums

Inserting ads between categories in the content list (1 post)

  1. Jonny13
    Member
    Posted 1 year ago #

    Hi everyone,

    I have been smashing my head on the table for days about this problem.

    My issue is similar to inserting ads between posts in post list (content area).
    Im still quite new to wordpress so I have next to no coding skills :(

    My issue is I bought a theme off themeforest.com called Hades (http://themeforest.net/item/hades-bold-magazine-newspaper-template/3068665) its a fantastic theme but I cant place ads in the content area.

    Basically with this theme you can place the category sections in the homepage content area and posts will list under the categories. This then means I cant use the the normal way of inserting ads between posts in post list.

    I have managed to narrow down the code to the bottom of a file called template-category.php.
    I have also found the area where to place code for adverts but it just repeats the same ad code under every category (See here: http://176.32.230.22/streetzine.co.uk/wp-content/uploads/2013/06/Screen-shot-2013-06-20-at-11.28.40.png), I would like to have the adverts placed the same but different under each category.

    This is my sites URL: http://176.32.230.22/streetzine.co.uk/

    This is the code of the the file called template-category.php:

    [please mark any posted code - http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

    <?php
    $category_obj = get_category($content_category_id);
    $category_posts = query_posts('category_name='.$category_obj->slug.'&posts_per_page=5');
    // Reset Query
    wp_reset_query();
    //pp_debug($category_posts);
    
    if(!empty($category_posts))
    {
    ?>
    
    <div class="post_wrapper">
    
        <div class="post_inner_wrapper">
    
        <div class="post_header_wrapper">
            <div class="post_header">
            	<h3>
            		<?php echo $category_obj->name; ?>
            	</h3>
            </div>
        </div>
    
        </div>
    
    </div>
    
    <?php
    $image_thumb = '';
    
    if(has_post_thumbnail($category_posts[0]->ID, 'blog_ft'))
    {
        $image_id = get_post_thumbnail_id($category_posts[0]->ID);
        $image_thumb = wp_get_attachment_image_src($image_id, 'blog_ft', true);
    }
    ?>
    
    <div class="post_wrapper">
    
        <div class="post_inner_wrapper">
    
    		<div class="one_half">
            <?php
                if(!empty($image_thumb))
                {
            ?>
    
            <div class="post_img">
                <a>ID); ?>" title="<?php echo $category_posts[0]->post_title; ?>">
                	<img src="<?php echo $image_thumb[0]; ?>" alt="" class="home_category_ft"/>
                </a>
            </div>
    
            <?php
                }
            ?>
            </div>
    
            <div class="one_half last">
            	<h6 style="margin-top:20px">
            		<a>ID); ?>" title="<?php echo $category_posts[0]->post_title; ?>">
            			<?php echo $category_posts[0]->post_title; ?>
            		</a>
            	</h6>
            	<div class="post_detail space" style="width:100%">
    	        	<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/clock.png" class="middle"/> <?php echo _e( 'Posted on', THEMEDOMAIN ); ?> <?php echo date('d M Y', strtotime($category_posts[0]->post_date)); ?>
    	    	</div>
    	    	<br class="clear"/>
                <?php
                	echo pp_substr(strip_tags(strip_shortcodes($category_posts[0]->post_content)), 120);
                ?>
    
                <a>ID); ?>" class="readmore"><?php echo _e( 'Read more', THEMEDOMAIN ); ?> →</a>
                <?php
    				$pp_enable_rating = get_option('pp_enable_rating');
    
    				if(!empty($pp_enable_rating))
    				{
    			?>
    	            <div class="post_category_rating">
    	            	<?php echo do_shortcode('[ratings id="'.$category_posts[0]->ID.'" results="true"]'); ?>
    	            </div>
    	        <?php
    	        	}
    	        ?>
            </div>
    
            <br "class=clear"/>
    
    <hr/>
    
    <?php
    foreach($category_posts as $key => $category_post) 
    
    if($key > 0)
    {
        $image_thumb = '';
    
        if(has_post_thumbnail($category_post->ID, 'thumbnail'))
        {
            $image_id = get_post_thumbnail_id($category_post->ID);
            $image_thumb = wp_get_attachment_image_src($image_id, 'thumbnail', true);
        }
    ?>
    
        <div class="one_half <?php if($key%2 == 0) { ?>last<?php } ?>">
        	<a>ID); ?>" title="<?php echo $category_posts[0]->post_title; ?>">
        		<img class="alignleft thumb" src="<?php echo $image_thumb[0]; ?>" alt=""/>
        	</a>
        	<a>ID); ?>" title="<?php echo $category_posts[0]->post_title; ?>">
        		<strong><?php echo $category_post->post_title; ?></strong>
        	</a>
        	<div class="post_detail space">
    	    	<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/clock.png" class="middle"/> <?php echo date('d M Y', strtotime($category_post->post_date)); ?>
    	    </div>
    	    <br class="clear"/>
        </div>
    
    <?php
    	if($key%2 == 0) {
    ?>
    	<br class="clear"/>
    <?php
    	}
    }
    
    //end foreach
    ?>
    
    	</div>
    
    </div>
    
    <div class="advert"><a href="http://www.diythemes.com/"><img src="http://diythemes.com/thesis/wp-content/uploads/2010/08/thesis-468x60.png" width="468" height="60" /></a></div>
    
    <?php
    
    }
    
    ?>

    Any help on this issue would be very much appreciated, and I hope I have explained it correctly.

    Thanks :)

Topic Closed

This topic has been closed to new replies.

About this Topic