ThemeShaper Forums » Thematic


Adjust Blog template to only display only category

(12 posts)
  • Started 7 years ago by proto
  • Latest reply from sathiz
  • This topic is not resolved
  1. proto

    Hi folks,

    I wondered if anyone knew how to adjust the blog template to display just one type of category. I've looked in the .php file that generates the blog and I've tried adjusting the code that I think needs to be used to display just my posts categorised as "blog":

    Here's the code I've adjusted:

    			$wp_query = new WP_Query();
    			$wp_query->query( array( 'category_name=blog&posts_per_page=3' => get_option( 'posts_per_page' ), 'paged' => $paged,  'category' => 'blog') );
    			$more = 0;

    It doesn't work I wondered if anyone on here knew what I needed to modify to ensure I only display a certain category on my blog page. Thank you for your assistance!

    Posted 7 years ago #
  2. prepare for facepalmage. you aren't using proper array syntax, since you are combining your code as a string when the existing code is using an array. if you had debug mode enabled in wp-config.php it might have told you this. maybe.

    $wp_query->query( array( 'category_name' => 'blog',
                             'posts_per_page=3' => get_option( 'posts_per_page' ),
                             'paged' => $paged,
                             'category' => 'blog' ));

    see the codex for examples:

    Posted 7 years ago #
  3. proto

    Thank you Helga!

    *Facepalmage was indeed in action!

    The only problem I have now is that the page thumbnails appear as small images to the right of text, does the code above alter the display?

    See what I mean here - the images are now small in the blog - under the old blog page template they appear the full width of the text around 540px wide below the text, they now appear small (78px wide) and to the right-hand side of the text? I did insert the image as full size text and set as featured image.

    Any thoughts! And thanks you ever so helpful (You are a ninja of Thematic!)

    Posted 7 years ago #
  4. this code does not alter display. that looks like default setup. you might need a combo of CSS and to filter thematic_post_thumb_size()

    Posted 7 years ago #
  5. proto

    Thanks Helga!

    I've looked with Firebug at both the default blog settings (leaving the code untouched and all posts displaying) where the images display nicely, full width of the container DIV and below the post content and then using your brilliant piece of code.

    There appears to be a CSS difference for some reason?

    The default code, where the images display nicely full container width, makes the images have an alignLeft size-full css styling:

    .alignleft size-full

    Can I include this class in my array so that is displays like the default view for images? Also, can I include social media links (I've got the code from Add This) below each blog post, I checked thematics hooks but couldn't see one like thematic_belowblog. Can I get this in the array too?

    - Thank you (*thinking of new, as yet unused superlative here*)!

    Posted 7 years ago #
  6. sidenote, i'd also like to point out that THIS is pretty much my fav way of modifying the query:

    do you have a link? maybe a link to the default and also a link to something running the modification? i've never seen thematic have a size-full class on the images, b/c well they're usually only 100x100. what other changes have you made?

    i have looked at this locally with both thematic 0.9.8 and the new beta and cannot reproduce this issue. here's a sample of my thumbnail. i have nothing else going on in my theme except switching home to excerpts... have you done this or is it displaying full content?

    <img width="100" height="100" src="http://localhost/multi/wp-content/uploads/ThumbLeader-150x150.jpg" class="attachment-100x100 wp-post-image" alt="ThumbLeader" title="Permalink to Coming Soon: Shourouk new collection!">
    Posted 7 years ago #
  7. proto

    Hi Helga,

    Thanks so much for this. I setup compartive blog styles, one with the default blog template applied and one with the blog page template displaying posts from a single selected category. Two things I think I've discovered:

    1: The default setting, just using the native blog template - displays the post and it's full content (ie no excerpt). When I use the code you very kindly provided it changes the blog display to excerpts (thanks for your help).

    2: The images appear to be having different classes applied to them (could this be a full post / excerpt display thing?). Using Google Chrome 'inspect element' I've seen that the default blog page adds a class ""alignnone size-full wp-image-xx". Whereas with the helpful code you kindly provided the images are told to display 100 X 100 width and height?

    If you want here's a see if for yourself :)



    Is there a way to have the full post display under the selective category display so the images display the same as the default blog page template?

    Don't worry if you don't have time to look, it's just a strange one, any thoughts appreciated, if not don't worry!

    Thanks all the same!

    Posted 7 years ago #
  8. is the default blog page set as displaying your 'most recent posts' in your blog's reading setttings? if so, you don't really need a template anyway.

    this is all i can think of as the function thematic_content() controls where excerpts will be display, which is everywhere EXCEPT single posts and the front page and the blog index.

    from content-extensions.php :

    // Sets up the post content
    if (function_exists('childtheme_override_content_init'))  {
    	function thematic_content_init() {
    } else {
    	function thematic_content_init() {
    		global $thematic_content_length;
    		$content = '';
    		$thematic_content_length = '';
    		if (is_home() || is_front_page()) {
    			$content = 'full';
    		} elseif (is_single()) {
    			$content = 'full';
    		} elseif (is_tag()) {
    			$content = 'excerpt';
    		} elseif (is_search()) {
    			$content = 'excerpt';
    		} elseif (is_category()) {
    			$content = 'excerpt';
    		} elseif (is_author()) {
    			$content = 'excerpt';
    		} elseif (is_archive()) {
    			$content = 'excerpt';
    		$thematic_content_length = apply_filters('thematic_content', $content);

    if you want your modified template to show the full contents of each post you could either edit the template and replace thematic_content() with the_content() or you could try filtering thematic_content

    function kia_child_content($content){
         $content = 'full';
      return $content;
    Posted 7 years ago #
  9. proto

    Thanks a lot Helga,

    Much appreciated, you really are a credit to this forum. I tried the filter and unfortunately it didn't work but thanks again, I really have ran out of superlatives to say thank you! :)

    Posted 7 years ago #
  10. sathiz

    Your post was very helpful to me. Thank you!
    But i have one problem:
    I have Archives links on the sidebar. When I click on it, i can see all the categories list... instead of just the category "blog". can you please help me with that.

    Thank you!

    Posted 7 years ago #
  11. @proto, i don't know if you ever solved your issue with this. be advised, that the blog template is being deprecated.

    also keep in mind that an archive of a single category is already built in to wordpress... its just the category archive!

    i should probably remove my filter as that is very wrong. well it is actually perfect, but that particular filter doesn't work with page templates, b/c by the time that filter runs, the query has been obliterated and replaced by the new query object in the blog template. by the time you get to thematic_content it doesn't even know it is ON a page template any more.

    you'd do better to test if you are on a category page or on a specific category page



    those should work instead.

    @sathiz- 1. why would you post a new question in this thread? 2. your question makes little sense to me. please start a new thread for your new question and try to be clearer in explaining it.

    Posted 7 years ago #
  12. sathiz

    here is the new thread link for the new topic.


    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.