• Resolved danicahodge

    (@danicahodge)


    I am working on my first website using WordPress tools (sorry, it’s not hosted yet, so I can’t provide a link). I am using Twenty Ten as the site template and loving it, but am trying to tweak a couple of things. I am new to CSS and PHP.

    1) I’d like to include the images that are in my posts on the category view (archive or index) for those posts. I’d still like to provide excerpts, if possible, but if not, I’d rather include the entire post.

    2) I’d like to offer one of my sidebar menus as a drop-down menu, but can’t find how to convert it.

    Thanks for any help you can offer.

    Danica

Viewing 11 replies - 1 through 11 (of 11 total)
  • loop.php, this part here:

    <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
    			<div class="entry-summary">
    				<?php the_excerpt(); ?>
    			</div><!-- .entry-summary -->
    	<?php else : ?>

    the_excerpt could be changed to the_content as you stated

    or possibly you could work some kind of custom excerpt to include the images. But that is the place to start.

    What kindof menu are you trying to get to be a dropdown? Like using the custom menu widget?

    Thread Starter danicahodge

    (@danicahodge)

    Thanks for your help. That seems to work, and now I have all of the content on the page. Do you know how I might work the image into a custom excerpt? I would rather have a shorter version on the index page, but I definitely want to include the image, and all of the other excerpt info I’ve seen only includes the text.

    As for the drop-down menu, I want to include a custom menu of post categories as a drop-down. Most of my site is static pages, and I do want those in outline form (which this template does), but I’d rather have categories as drop-down, if possible.

    Thanks again.

    Hi,
    As you are working on your first WordPress using the twenty ten theme, can I suggest that you look at using a child theme, this gives a small set of files to work with and an easy return point if you want to revert anything.

    I have a twenty part series of short tutorials, for the Twenty Ten theme that you may find of use, if not there is a post on using post images for your lists.

    Using menus and menu locations allows you to add pages, posts, categories and links in the menu in any order or indentation, there is a built in sidebar menu, create a menu and add it.

    HTH

    David

    Thread Starter danicahodge

    (@danicahodge)

    Thanks, I forgot to mention that I am actually using Twenty Ten Weaver, which is a child theme of Twenty Ten. Which is great, because I actually was messing with code earlier and really did create a real mess that I was thankfully able to mop up by re-downloading WordPress and the theme.

    When I just use the categories widget that comes with WP, it has the option to be a dropdown within the actual widget settings. Is that not true for you?

    as for customizing content and keeping pics…. this is untested, but:

    in functions.php put

    function content($limit) {
      $content = explode(' ', get_the_content(), $limit);
      if (count($content)>=$limit) {
        array_pop($content);
        $content = implode(" ",$content).'...';
      } else {
        $content = implode(" ",$content);
      }
      $content = preg_replace('/\[.+\]/','', $content);
      $content = apply_filters('the_content', $content);
      $content = str_replace(']]>', ']]>', $content);
      return $content;
    }

    and then in loop.php where we were editing, instead of
    <?php the_content(); ?>

    put

    <?php echo content(50); ?>

    it used to work….haven’t used it ina while, and forget where I got the code. Also, the number 50 is editable, that is teh word count

    Thread Starter danicahodge

    (@danicahodge)

    Wow, I’ll try that code, thanks.

    When I had another theme installed (was using Magazine Basic), I was able to make the menu a drop-down. When I switched to Twenty Ten, it actually kept the drop down, but when I had to re-download the theme again (see above screw up) it went away. Hmmm, I wonder if I could switch to Magazine Basic, select drop down, and then switch back? Sounds too easy to work.

    Thread Starter danicahodge

    (@danicahodge)

    Oh, I see my problem for the menu. I just need to use the Categories button instead of Custom Menu in the widget bar. Easy.

    Thread Starter danicahodge

    (@danicahodge)

    OK, the “get the content” code didn’t work (everything vanished off the page), but I sent it back to its original state. If anyone has an easy fix for this, it’s appreciated.

    This should works for Twenty Ten and Twenty Ten Child Themes.

    As you are using a twenty ten this should be quite easy, in the folder you might have a loop-index.php file, if not find the loop file, if you cannot find the file, child theme copy loop.php across to the child theme, open loop.php and save as loop-index.php.

    Open the file and where you see:
    <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?>

    Remark This call

    <?php //REMARK CALL the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?>

    Add the call to the excerpt directly under the line

    <?php //REMARK CALL the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?>
    <?php the_excerpt(); ?>

    Other List Outputs
    Once you are happy with the loop output, if you want the same look for all list output.
    Save loop-index.php as loop-category.php
    Save loop-index.php as loop-archive.php
    Save loop-index.php as loop-search.php

    Excerpt Length Standard 55 Words
    If you find that there are to many words in the excerp you can adjust these by changing the excerpt length from this Codex

    function new_excerpt_length($length) {
    	return 20;
    }
    add_filter('excerpt_length', 'new_excerpt_length');

    If you are using a child theme it would go in the ‘after_setup_theme’ or you can add it at the end of the functions.php inside its own function.

    function change_excerpt_length(){
       function new_excerpt_length($length) {
       	return 20;
       }
       add_filter('excerpt_length', 'new_excerpt_length');
    }
    add_action( 'after_setup_theme', 'change_excerpt_length' );

    Now when ever you call <?php the_excerpt(); ?> Twenty words are returned instead of 55.

    HTH

    David

    Thread Starter danicahodge

    (@danicahodge)

    Thank you so much for your response. I actually ended up downloading a couple of plugins that got me closer to where I wanted to be. They were Thumbnail for Excerpts and Regenerate Thumbnails. The first worked perfectly with the standard template to give me my images on the categories page. Now my problem is how to resize the thumbnails, because Regenerate Thumbnails didn’t work, but I’ll check the other forums. I’ll go ahead and mark this as resolved, anyway. You guys are great!

    Kvarnexperten

    (@kvarnexperten)

    I don’t know the exact definition of a drop-down menu, but with a free plugin called jQuery Categories List Widget you should get a tree view with your top categories as expandable/collabsible branches. Kinda.

    I use it on kvarnexperten.se/wp (under “Inneh?ll” on the right), but I have tweaked the code so that it does not collapse but always displays all items.

    I found this thread searching for ways to include post images in category view, thanks for putting me on track!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘How to include post images in category view Twenty Ten template’ is closed to new replies.