• Resolved quickdry

    (@quickdry)


    Hi, just updated and version 2.0.54 is showing “read more” on all old layouts using the “Excerpt” field – note these are specifically the “Excerpt” and NOT “Excerpt with read more”.

    The error seems to be in post-grid/includes/functions/post-grid-layout-elements.php

    Function post_grid_layout_element_excerpt() includes the code to display the “read more” even though it is just an excerpt not “excerpt with read more”.

    I tested and removing lines 443-448 (or making the “if” statement always false) returns “old layout” grids using “Excerpt” to the old/expected behaviour.

    I’m not a php guy so I can’t tell you why the $read_more_text variable is being set to “Read More” in old grid layouts that use “Excerpt”).

    “Excerpt with read more” still works as normal because it has a different function. (This change _would_ make the “read more text” settings irrelevant and unused in New Layout grids using “Post Excerpt” – but it fixes the old layouts, and both Exerpt elements behave as you’d expect – I’d use “Excerpt with Read More” if I wanted “read more”)

    (Also, thanks for making and supporting this plugin, it’s really great. Any chance we could get a “copy grid” from the main grid listing?)

    • This topic was modified 4 years, 10 months ago by quickdry.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter quickdry

    (@quickdry)

    Hi, will this fix (or another fix) be in a patch release soon?

    (it feels a little like shouting into the wind despite offering a fix to the bug)

    Plugin Author PickPlugins

    (@pickplugins)

    Thanks for your post,

    Sorry for the taking time, i have removed default “Read more” text, please try the let’s version “2.0.55” and let me know the result.

    Regards

    Thread Starter quickdry

    (@quickdry)

    that one is worse – it may not show “read more”, but now it is including the first paragraph of text from the post instead of the “excerpt” field which is defined in the layout (it even obeys the word limit’s defined in the template, but applies that limit to the post’s text )

    Plugin Author PickPlugins

    (@pickplugins)

    Let me check the issue, will fix and update plugin.

    Regards

    Thread Starter quickdry

    (@quickdry)

    it looks like a copy paste of some old code – cause in line 428 you’d commented out the very bit of code that grabs the excerpt, and have post_content instead.

    this is what the function should look like and seems to be working (it immediately fixes the excerpt vs post content issue.)

        function post_grid_layout_element_excerpt($args){
    
        $element  = isset($args['element']) ? $args['element'] : array();
        $elementIndex  = isset($args['index']) ? $args['index'] : '';
    
        $post_id = isset($args['post_id']) ? $args['post_id'] : '';
    
        if(empty($post_id)) return;
    
        $layout_id  = isset($args['layout_id']) ? $args['layout_id'] : '';
        $the_post = get_post($post_id);
    
        $post_excerpt = get_the_excerpt($post_id);
    
        $post_link = get_permalink($post_id);
    
        $link_target = isset($element['link_target']) ? $element['link_target'] : '';
        $custom_class = isset($element['custom_class']) ? $element['custom_class'] : '';
        $char_limit = !empty($element['char_limit']) ? (int) $element['char_limit'] : 50;
        $read_more_text = isset($element['read_more_text']) ? $element['read_more_text'] : '';
    
        if($char_limit > 0){
            $post_excerpt = wp_trim_words($post_content, $char_limit, '');
        }
    
        ?>
        <div class="element element_<?php echo esc_attr($elementIndex); ?> <?php echo esc_attr($custom_class); ?> excerpt ">
            <?php echo ($post_excerpt); ?>
            <?php
            if(!empty($read_more_text)):
                ?>
                <a target="<?php echo esc_attr($link_target); ?>" href="<?php echo esc_url_raw($post_link); ?>"><?php echo esc_html($read_more_text); ?></a>
            <?php
            endif;
            ?>
        </div>
        <?php
    }
    
    Thread Starter quickdry

    (@quickdry)

    It doesn’t really mess up my layouts, but in the old layouts “Post Date” was not a link, but now when an old layout is used, it shows that date as a permalink to the post.

    It’s a similar issue to the “read more”, options that didn’t exist on old layouts are assumed to be turned on in the new layouts – it works with the data of a new layout, but not on an old)

    That one isn’t a showstopper for me and I’m sleepy so I didn’t dig into it – but at line 1087 you set the “link_to” value. By default/on old layouts, that is set to “post_link”. Is there a value/way of telling that a layout is an “old layout”? Then you could just do something like:

    if ($old_layout){ $link_to = 'Nothing'; } //now Post Date won't set itself as a link.

    Plugin Author PickPlugins

    (@pickplugins)

    I understand the issue, we will not continue fixing issue for old layout, but definitely will solve conflict, don’t worry,

    I would recommend using new layout, its so easy to convert old layout to new layout, please watch this video

    Please try latest version 2.0.56 i have fixed excerpt and link to post date issue. let me knwo the result.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘“read more” showing on old layouts using “Excerpt” (inc fix)’ is closed to new replies.