ThemeShaper Forums » Thematic

[closed]

Add a feature post section in child theme

(22 posts)
  • Started 9 years ago by adavis3105
  • Latest reply from rscamero92
  • This topic is not resolved
  1. adavis3105
    Member

    I am trying to build a feature post section in a thematic child theme ..I need the section to include both images and text as it is for a magazine site and thats one of their requirements. I took a quick look at the Acamas theme and it doesnt appear to support images in the home page.

    Am I missing something with Acamas? or is there a way I can add a feature section to my current work-in -progress child theme?

    Posted 9 years ago #
  2. 11thinking
    Member

    Check out this post

    Posted 9 years ago #
  3. adavis3105
    Member

    It sort of gave me what i wanted....I want the feature story to only appear once on the home page...right now, it is appearing twice.
    The only change I have made to the code so far is to go from this

    $my_query = new WP_Query('tag=featured&showposts=3');

    to this

    $my_query = new WP_Query('tag=feature&showposts=1');

    Is there any way to change this so that a specific category is the content for the feature post and not a tag?

    Posted 9 years ago #
  4. @adavis - of course. change tag=feature to cat=whatever ..

    see the codex for parameters: http://codex.wordpress.org/Template_Tags/query_posts

    anybody figure out how to exclude the featured posts from the regular loop? so that they do not appear 2x on the index page?

    Posted 9 years ago #
  5. wasn't this resolved in the cozmolabs forum?
    http://www.cozmoslabs.com/forums/topic/featured-posts

    Posted 9 years ago #
  6. adavis3105
    Member

    @helgatheviking- that did the trick thanks...one more question...how do I make the featured section appear above the sidebar...so what I would like to do is have the feature section span the width of the content area then have the other posts and sidebar appear below

    Posted 9 years ago #
  7. adavis, that question was covered in the above link
    http://www.cozmoslabs.com/forums/topic/featured-posts

    Posted 9 years ago #
  8. adavis3105
    Member

    Jonny Janerio- that code immediately broke my site....not sure why...so hopefully there is another solution out there to get the featured post to span the whole width

    Posted 9 years ago #
  9. adavis,
    i havent tried Acamas theme.

    but did try the code above in child theme just out the box, few ammendments...
    *got rid of ul cos you only wanted one post to show.
    *found i needed to use category_name= instead of cat=
    *added post thumbnail support to display front thumbnail (you could further extend this for all posts, etc

    you can see the demo working here
    http://www.dev.virtualpudding.com/

    the functions.php

    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 180, 180, true );
    
    $ids = array(); // here we'll save the post id's that are listed in the featured area. It's a global variable
    
    function featured_posts(){
    	if (is_home() || is_front_page()) {
    		global $ids; //telling php to use the global variable
    
    		$my_query = new WP_Query('category_name=featured&showposts=1');
    
    		echo '<div id="featured-holder"><div class="featured-content">';
    		$feat_class = array();
    
    		while ($my_query->have_posts()) : $my_query->the_post();
    				$feat_class = array();
    				// Category for the post queried
    				foreach ( (array) get_the_category() as $cat )
    					$feat_class[] = 'category-' . $cat->slug;
    					$feat_class = join(" ", $feat_class);
    				?>
                    <?php the_post_thumbnail(); ?>
                    <?php thematic_postheader(); ?>
    					<?php the_excerpt(); ?>
    
    		<?php
    
    		$ids[] = get_the_ID();
    		endwhile;
    
    		echo '</div></div>';
    	}
    }
    add_action('thematic_belowheader','featured_posts');
    
    // We'll remove the main thematic loop because we recreated it in the above function.
    function remove_thematic_indexloop(){
    	remove_action('thematic_indexloop','thematic_index_loop');
    }
    add_action('init','remove_thematic_indexloop');
    
    function child_indexloop(){
    	global $ids; //telling php to use the global variable
    
    	//Recreate the main loop and exclude the posts that have been displayed
    		while ( have_posts() ) : the_post() ?>
    
    			<?php 
    
    			// If an ID has been listed in the above list we won't list it again.
    			if (!in_array(get_the_ID(), $ids)) { ?> 
    
    				<div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
    					<?php thematic_postheader(); ?>
    					<div class="entry-content">
    					<?php thematic_content(); ?>
    
    					<?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'thematic') . '&after=</div>') ?>
    					</div>
    					<?php thematic_postfooter(); ?>
    				</div><!-- .post -->
    
    					<?php comments_template();
    
    					if ($count==$thm_insert_position) {
    							get_sidebar('index-insert');
    					}
    					$count = $count + 1;
    			}
    		endwhile;
    }
    add_action('thematic_indexloop', 'child_indexloop');

    this is what went in my css

    #featured-holder {
        width:940px;
        margin:20px auto 0 auto;
        overflow:hidden;
        position:relative;
    }
    .featured-content {
        min-height: 200px;
        background:#f1f1f1;
        border:3px double #ccc;
    	padding:10px;
    
    }
    .featured-content img {
    	float:left;
    }
    h1,h2,h3,h4,h5,h6 {
    clear:none;
    }

    you will have to build upon the css, i scraped it together.

    what is the h1,h2,h3,h4,h5,h6 clear:none
    well, i found it an easy solution when floating post thumbnails
    ref here
    using this method, i haven't come across any problems as yet but there are probably more effecient ways of doing this.

    hope any of this helps you towards the right track

    Posted 9 years ago #
  10. oh, and if you want to keep the original codes hover
    css

    .featured-content:hover {
    	background:#fff;
    }
    Posted 9 years ago #
  11. neato!! actually if you keep the showposts at 3 or whatever, it is not too much further to create a slider! i need to work out a few kinks, but i think i have it working w/ flowplayer.

    Posted 9 years ago #
  12. well the akismet fairies have caught me again and won't let me post my code (nor start a new post on the subject).

    so here is my code for integrating the jQuery tool's slideshow into the featured posts. i dont have a live demo but it should function similar to: http://static.flowplayer.org/tools/demos/tabs/skin4.htm

    the functions code:

    http://pastebin.com/9BKwrbsb

    and the CSS:

    http://pastebin.com/JKauTtHi

    i suspect it will not work on thematic 0.9.6.2 so be sure to test it out w/ the latest stable dev version instead. if you come up w/ some improvements or find errors, let me know as it certainly hasn't been heavily tested.

    Posted 9 years ago #
  13. nice one helga. will take a look now.
    maybe the tooth fairies pissed them off

    Posted 9 years ago #
  14. maybe that's it! idk, it is frustrating... i go to the effort of writing out long posts and then whoooosh... they don't get posted. at least i know enough to hit "copy" before i hit post.

    Posted 9 years ago #
  15. adavis3105
    Member

    Ok something isn't right here...I took your code, pasted it into the function.php page, made the required changes ( the category name) , update the file and then when i look at the page, no featured category, no images in the post...all of it now gone....

    So the original code for making the feature post worked, I still need a solution to stop the duplication of the content below the feature post.....

    Posted 9 years ago #
  16. adavis,
    that code i posted did achieve what you wanted. you can see from demo.
    i'm at a loss to why it isn't working in your theme sorry.

    Posted 9 years ago #
  17. do you not have any posts in the featured category? otherwise the query will be empty. outside of that idk what to tell you either. his code worked for me too.

    @johnny did you get a change to try my slider?

    Posted 9 years ago #
  18. helga,
    yeah tested. works great! good work, very neat.

    at first, couldn't get it going. pulling hair out (even considered the 'wine' approach).
    the problem? you reverted the code back to 'tag' and not 'category_name' and i had 'featured' as categories. the joys.

    Posted 9 years ago #
  19. cool! and sorry about the tag thing. i probably should have mentioned that! to anyone else you cares to try/use my above code not that the featured query is looking for posts TAGGED "featured" whereas Johnny's code looks for a featured category.

    do you think it makes sense to move all the relevant code for that type of page to a template that can be dropped into any child theme?

    Posted 9 years ago #
  20. doesn't seem to work in ie7
    not tested in ie8

    Posted 9 years ago #

  21. Posted 9 years ago #
  22. Ignore my post. I answered my own question a few minutes after posting here. Not my day to try to think and design at the same time! ;)

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.