Site logo

Archived topic

A couple questions on archives and post formats

7 replies · Started by David on May 22, 2019

Viewing posts 1–8 of 8

For link and audio post formats, I would like the excerpt word count to match that of standard posts and display a read more button.

For quote posts, is it possible to assign a link to div.inside-article so that if I click anywhere on the quote box it links to a single page for that quote? Additionally, what is the best way to display only the quote on the archive page? I have considered applying a css class to additional text to hide on the archive page, but is there a better way?

Thanks

Hi there,

1. Try this function:

add_filter( 'generate_show_excerpt', function( $show ) {
    if ( 'link' === get_post_format() || 'audio' === get_post_format() ) {
        $show = false;
    }

    return $show;
} );

2. This would likely require some javascript. If we targeted the first link in the post, would that work?

3. I think the CSS class is the best method :)

Thanks for the quick reply Tom.

1. I added the function, but it does not seem be doing anything. For audio posts, I basically want to display the podcast + the 55 word count and read more button as shown on my standard post formats on the archive page.

2. I'm actually trying to target the permalink for that particular post. For example, I'd like to show a quote block on the archive page, but when you click anywhere on the quote block you are linked to the single page with the quote plus some paragraphs describing the significance of the quote.

3. I was able to achieve this with CSS, but I'm currently adding a class to each block following the quote. Is there a way to add a class to the first block (the quote) and display that block only? I tried some variants using CSS display and visibility properties with no luck.

1. Ah, so you still want to show the excerpt, but you want to include podcast. You may need to use the More Tag: https://docs.generatepress.com/article/using-the-more-tag/

2. Try this:

1. Create a Hook Element: https://docs.generatepress.com/article/hooks-element-overview/
2. Set the hook to wp_footer
3. Set the Display Rules to your archives (not single posts)
4. Add this as the content:

<script>
    jQuery( document ).ready( function( $ ) {
        $( '.format-quote' ).on( 'click', function() {
            var _this = $( this ),
            url = _this.find( '.entry-title a' ).attr( 'href' );

            if ( url ) {
                window.location.href = url;
            }
        } );
    } );
</script>

Then you'll need some CSS:

.home .format-quote,
.archive .format-quote {
    cursor: pointer;
}

3. The quote itself should have an additional class field in the editor. Is that not working?

1. I was not familiar with the More block. That will do, thank you!

2. I've added the hook and CSS. The CSS is working fine, but when I hover/click on the quote it does not appear to be targeting anything?

3. Yes, I see the additional class field, but currently I am using CSS to hide the content after the quote, which may be several blocks using the following:

.home .quote-content {
    display: none;
}

I was wondering if there was an alternative in which I could display only the first block, or what I've defined as .quote-block? Hiding the additional content is working fine, just more repetitive (having to assign a class to each additional block) than the alternative if possible.

BTW, the support on this site is second to none! I really appreciate it since I am in no way a developer and am just learning this for fun/personal use.

2. I'm not seeing the javascript on the page. Can you double-check that the Display Rules are correct?

3. You could try this:

.home .format-quote .entry-content > *:not(.wp-block-quote) {
    display: none;
}

Let me know :)

Yes, everything is working now. Thank you so much! I realized I needed to set the display rules to blog instead of archive, but it's working fine now. Thanks again!

You're welcome :)

This archived topic is closed to new replies.