simple-lightbox icon indicating copy to clipboard operation
simple-lightbox copied to clipboard

get_the_excerpt() destroys SLB

Open stevie77 opened this issue 9 years ago • 5 comments

SLB is working perfectly on all pages and posts for my theme Nirwana and with all my plugins. Only if I use get_the_excerpt() in the same page with an image, then the image is opened in the browser instead of a SLB popup box. If I omit the call of get_the_excerpt(), then all posts are shown without the excerpt and everything works fine (SLB is showing the image correctly).

I have a normal WordPress page (newest version) with an image:

<a href="http://www.radtrekkingblog.de/wp-content/uploads/2016/10/Silvretta-Hochalpenstraße1.jpg"><img src="http://www.radtrekkingblog.de/wp-content/uploads/2016/10/Silvretta-Hochalpenstraße1-300x200.jpg" alt="Silvretta-Hochalpenstraße (Bielerhöhe)" width="300" height="200" class="alignleft size-medium wp-image-1678" /></a>

Beneath I have following PHP code to show all posts of a certain tag in the loop (had to remove some characters for being able to show as formatted code):

<?php 
    $the_query = new WP_Query(posts_per_page=200&tag=.$tag.&order=ASC);
    while ($the_query -> have_posts()) : $the_query -> the_post(); 
?>
    <div class="entry-meta" style="padding: 1px 1px;">
        <h4 class="entry-title">
            <a class="hoverDisabled" href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a>
        </h4>
        <span style="width: 100%;">
            Kategorien: <?php the_category(","); ?>
        </span>
    </div>
    <?php 
        nirvana_set_featured_thumb();
        $excerpt = get_the_excerpt();
        echo slb_activate($excerpt);
    ?>
<?php 
    endwhile;
    wp_reset_postdata();
?>

Normally I use the plugin 'PHP Code For Posts' with a shortcode to execute the PHP code but in order to exclude an issue with the plugin I embedded the code directly in the page (with the same behaviour).

When I look at the code of the page in the browser, there is one difference (see attached files): When I use the WordPress function get_the_excerpt() all the lines in attached file missing-lines.txt are missing (responsible for showing SLB, I guess).

Files:

missing-lines.txt with-get_the_excerpt.txt without-get_the_excerpt.txt

stevie77 avatar Oct 30 '16 23:10 stevie77

Hi, do these posts have manual excerpts or are the excerpts generated from the posts' content? If the latter, then it looks like your theme or a plugin may be running code that affects the excerpt output. When done incorrectly, such code can break all other plugins that interact with a post's content (including SLB).

I would recommend checking your theme/plugins for conflicts. Here are instructions for identifying plugin/theme conflicts. Let me know what you find and I would be glad to take another look if necessary.

archetyped avatar Nov 02 '16 02:11 archetyped

Hello, sorry for not replying immediately. The excerpt is generated automatically from the post content. I deactivated my Theme Nirwana (WP Twenty Fifteen in use now) and deactivated all plugins without Simple Lightbox (as expected g) and PHP Code For Posts. This is the plugin where some php code is called via the WordPress page. The code executes a query to get posts of a certain tag. If I use the line the_excerpt(); for showing the excerpt the SLB doesn't work (picture in browser). If I use // the_excerpt(); (no usage) then SLB works perfectly (but shows no excerpt, as expected). As the_excerpt(); is a WordPress function I think there is a problem with SLB and this WordPress function. My theme seems to be innocent. ;-) The PHP code plugin also works correctly because it can handle the PHP code without the excerpt (and some other small code snippets without calling the_excerpt();). I also tried $excerpt = get_the_excerpt(); echo slb_activate($excerpt); instead of the_excerpt(); as I read this as an hint somewhere, but with same result. Any ideas?

stevie77 avatar Nov 06 '16 18:11 stevie77

Hi, HTML is stripped from automatically-generated excerpts by default, so if there are image links in the output from the_excerpt(), then there must be some other code (such as from a plugin) that is modifying the_excerpt()'s output.

I would recommend deactivating all other plugins when testing for conflicts, since a plugin can cause a conflict with another plugin even if it appears to be working properly itself. If SLB is still not working when all other plugins have been disabled and a default template (such as Twenty Fifteen), please provide a link to a page that exhibits the issue you are experiencing and I would be glad to take a closer look.

archetyped avatar Nov 07 '16 03:11 archetyped

Hi, I've tested it without any activated plugins but SLB and 'PHP Code For Posts' (I need this plugin to create the query that influences SLB in that negative way). There is no HTML or any image link in the generated excerpt. There is a link to runtastic.com for my GPS tracks in the text that is being processed, but this link is not contained anymore in the excerpt. Is it a problem, that the HTML link exists before being processed by the_excerpt()? The image link, that isn't working with SLB, is located on top of the site (outside the query and representation by the function excerpt). Please have a look here: http://www.radtrekkingblog.de/archiv/jahr2015/norwegen-2015 The first bigger picture doesn't work with SLB, and after that my PHP code lists all posts with the tag for my Norway trip in 2015. If you open one of the posts (e.g. http://www.radtrekkingblog.de/norwegen-20-06-2015) and click there on the first image on top you can see SLB working (because on this WP site the function the_excerpt() is not called).

stevie77 avatar Nov 07 '16 03:11 stevie77

I've tested it only with the 2 plugins mentioned and a standard WP theme to check if there is a problem with my theme or other plugins, but do YOU want to see it with the standard WP theme and deactivated plugins? At the moment the Nirwana theme (respectively my child plugin) is activated because the site is online and I prefer visitors to see it with the intended design. ;-)

stevie77 avatar Nov 07 '16 03:11 stevie77