• Hi

    I’d like to pull in certain posts that belong to a category on the homepage. E.g. ‘Featured’ category, etc.

    1) I’d like it to show the first paragraph. (Or however many chars I specify, e.g. first 300 chars)
    2) I’d like it to preserve any links that it finds within this first paragraph.

    How do I do the above?

    Kind Regards
    Alex

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Eric Amundson

    (@sewmyheadon)

    Hi Alex,

    There are a few ways to do this. Here’s the solution that might be most flexible for you by allowing you to change the amount of content shown and preserving all formatting:

    1. Copy posts_loop_template.php from the plugin directory to the root of your theme directory.
    2. Open posts_loop_template.php in your theme directory and change line 22 from <?php the_excerpt(); ?> to <?php the_content(); ?>
    3. Use the More tag in your posts to indicate where they should be truncated. You can see this technique illustrated at the top of the Customizing the Read More page under The Excerpt Basics (option 1). In short, you add the more tag in each post where you’d like it to cut off in category view.
    4. On the page where you’d like to bring in the loop, use a shortcode like this: [ic_add_posts category='featured'] (where ‘featured’ is the slug of your category.

    A few notes about this solution:

    1. This solution will apply the modified posts_loop_template.php file to all uses of your Posts in Page shortcodes.
    2. If you wish to use multiple custom output formats with Posts in Page, you’ll need to specify the output template in your shortcode like so: template='template-in-theme-dir.php'
    3. This does require you to add the <!– more –> tag to each post; otherwise it’ll display at full-length.

    Does this make sense? Is it helpful?

    I thought it the most flexible way because it accommodates posts with first paragraphs of widely-differing lengths.

    Eric

    Thread Starter Lab41

    (@lab41)

    Hi Eric

    That is a great solution! Thanks.

    The only issue is that my themes auto update and I want to use this on multiple sites. Will the auto update overwrite the modifications?

    Is there a way to keep it as a plugin or maybe a functions code snippet I can use? This way it can handle the auto updates.

    Basically, what I’m trying to achieve is to get a link on the homepage by showing snippets/excerpts of certain posts. I know it sounds easy but I’ve searched for ages and struggling to find a solution. Most advise modifying the theme!

    Alex

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Howdy @lab41,

    You’re welcome.

    The only issue is that my themes auto update and I want to use this on multiple sites. Will the auto-update overwrite the modifications?

    Ideally, you’d copy the posts_loop_template.php file/template to your theme’s root folder and edit it there. If you can’t do that because the theme is updating and replacing all files and you can’t keep your mods in the plugin for the same reason, two options would be to:

    • update the theme and replace the file manually (rather than via auto-update)
    • create a child theme and put the edited template in the Child so it’s not overwritten on update.

    I’ll check to see if there’s a possibility of housing your changes in a plugin instead and get back to you. We’re working on a Pro version and can see some benefits here.

    Thread Starter Lab41

    (@lab41)

    Hi

    1) update the theme and replace the file manually (rather than via auto-update) -> for 100 sites? Would be a painful job for whoever get’s that on their task list 😉
    2) Quite a workaround for this one feature.

    Would be awesome if this was in a pro version!

    Plugin Author Eric Amundson

    (@sewmyheadon)

    1. Yup, that would be a royal pain.
    2. True – I’m guessing you’re using a theme with a page builder or are otherwise storing customizations in your database.

    We’ll put our heads together and get back to you with more info soon. It might take a day or two, but I’ll follow up.

    Thread Starter Lab41

    (@lab41)

    Hi

    1) Massive pain. 🙂
    2) I use about 50 different themes for these sites. So customizing is a pain which is why I was thinking of a plugin solution.

    I’ve asked on a few forums as well and everyone recommends to modify the theme. So I guess there’s quite a need for something like this if it’s possible!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Showing Links In Excerpts’ is closed to new replies.