• I wonder if it’s possible to show an excert of the post on the main page when posted to a specific category?
    When clicking the “Read more..” link the visitor should be able to read the full post in the acrhive list of that caregory.

    TIA!

Viewing 11 replies - 1 through 11 (of 11 total)
  • It is probably possible by using a conditional tag:
    if is category X ==> show excerpt
    else ==> content.
    see http://codex.wordpress.org/Conditional_Tags

    However the excerpt does NOT display a “more” tag. And even clicking on a more tag (which, BTW, appears only when inserting the <more> quicktag when writing a post) it will never take you to the “archives list” but to the single post view of that post.

    in_category (not is_category) is probably the appropriate template tag you will need.

    http://codex.wordpress.org/Template_Tags/in_category

    The link to full article can be done like the following
    <a href="<?php the_permalink(); ?>">Read more...</a>

    Yep, listen to alphaoide when it come to code 🙂
    I might be good when it comes to the general idea, but my knowledge in coding is = 0.

    Thread Starter Aziza

    (@aziza)

    Thank you for your prompt replies! 🙂
    alphaoide: I’ll look in to that!

    Thread Starter Aziza

    (@aziza)

    Just a question, is it possible to use this code for this? (i’m not a programme so i’m a bit lost)
    The category I would like to do this with has the ID 12

    <?php if(is_category() || is_archive()) {
    the_excerpt();
    } else {
    the_content();
    } ?>

    I just need to verify. You need the following structure in Front Page, correct?

    Post in category regular
    --Show Content--

    Post in category special
    --Show Excerpt--

    Post in category regular
    --Show Content--

    Post in category regular
    --Show Content--

    Post in category special
    --Show Excerpt--

    If so, then you’d do the following.
    <?php if(in_category(12) || is_archive()) {
    the_excerpt();
    } else {
    the_content();
    } ?>

    Thread Starter Aziza

    (@aziza)

    YAAY! It’s working :)) Thank you!!
    Now.. is it possible to automatically have a link where the […] is to the category listing: cat=12 ?
    Alos, could I have more categories listed in the <?php if(in_category(12)? Like: <?php if(in_category(12,13,14)

    Now.. is it possible to automatically have a link where the […] is to the category listing: cat=12 ?
    The [...] is there to stay. You can’t modify it without hacking the source code.
    You could display the category of the post (which links to category listing) by using the template tag the_category()
    http://codex.wordpress.org/Template_Tags/the_category

    Alos, could I have more categories listed in the <?php if(in_category(12)? Like: <?php if(in_category(12,13,14)

    <?php if(in_category(12) || in_category(13) || in_category(14) || is_archive()) {
    the_excerpt();
    } else {
    the_content();
    } ?>;

    Thread Starter Aziza

    (@aziza)

    *doing the happy dance* Works like a charm!
    Thanks for your time and help! 🙂

    Thread Starter Aziza

    (@aziza)

    A new question 🙂
    What if I don’t want the comments link to show up below the excert when posted in that category?

    This is the code i’m using:

    <?php if(in_category(12) || in_category(13) || in_category(20) || in_category(21) || is_archive()) {
    the_excerpt_reloaded(25, ‘<img>’, ‘content_rss’, FALSE);
    } else {
    the_content();
    } ?><?php if ( in_category(’12’) ): ?><span class=”more-link”>Fortsätt läs här</span>
    <?php endif; ?>

    Thread Starter Aziza

    (@aziza)

    Solved it!

    Using:

    <?php if(in_category(12) || in_category(13) || in_category(20) || in_category(21) || is_archive()) {
    comments_number(‘Inga kommentarer’, ‘1 kommentar’, ‘% kommentarer’, ‘number’);
    } else {
    smart_comments_popup_link(__(‘Inga kommentarer än’), __(‘1 kommentar’), __(‘% kommentarer’));
    } ?>

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Show excert of post in specific category’ is closed to new replies.