• Hello,

    Right now when someone clicks on the Archives or on the Categories they get the full posts. I would like that instead of the full posts they get a list (maybe displaying the post title and excerpt) from which to choose.

    (WP 2.7, iNove)

    Mike

Viewing 8 replies - 1 through 8 (of 8 total)
  • I’m not familiar with the theme but I assume it is using the_content()

    Just change that template tag to the_excerpt()

    By default, when using the_excerpt() WordPress will display the first 55 characters from your post. If you want to alter that place this in your theme’s function.php file,

    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'custom_trim_excerpt');
    
    function custom_trim_excerpt($text) { // Fakes an excerpt if needed
    global $post;
    if ( '' == $text ) {
    $text = get_the_content('');
    $text = apply_filters('the_content', $text);
    $text = str_replace(']]>', ']]>', $text);
    $text = strip_tags($text);
    $excerpt_length = x;
    $words = explode(' ', $text, $excerpt_length + 1);
    if (count($words) > $excerpt_length) {
    array_pop($words);
    array_push($words, '...');
    $text = implode(' ', $words);
    }
    }
    return $text;
    }

    Adjust the line $excerpt_length = x; to whatever you want.

    Thread Starter mdelaflor

    (@mdelaflor)

    Thanks for you reply. Where do I find the template tag? what file is that in usually?

    Mike

    I’ll have a look at the theme.

    archive.php is the file you want.

    More reading on the_content() and the_excerpt()

    Thread Starter mdelaflor

    (@mdelaflor)

    I found this <?php the_content(); ?> in the page.php file in the inove directory.

    I changed it to <?php the_excerpt(); ?> but nothing changed.

    I still get full posts and not a list. Maybe I changed the wrong file.

    Mike

    in the page.php file

    That would change pages, not archives. You need to change the archive.php file.

    Thread Starter mdelaflor

    (@mdelaflor)

    Thank you! That was a great help and it worked exactly as I wanted. Its nearly 1 am in the morning and I am bit tired. I did look in the archive.php file but I missed it. Do I have to change it in archives.php also? This file has an S after the word archive.

    I am determined to get one other thing working before calling it a night. I have created a static page (see https://www.delaflor.com/articles-tutorials) where I want to display a list of all archives and catagories. I used the plugin called smartarchives.php and exec-php. But I am not having any luck. Do you have any ideas on how to creat such a page?

    Mike

    Do I have to change it in archives.php also

    generally speaking, it shouldn’t even be in archives.php.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How can I change how archived and categorized materials display?’ is closed to new replies.