• Hello,

    Out of nowhere the caption tag stopped working.

    HTML from editor:
    [caption id="attachment_685" align="aligncenter" width="300"]<a href="https://higraf.no/wp-content/uploads/2016/09/iStock_67284239_XXXLARGE-resize.jpg"><img class="size-medium wp-image-685" src="https://higraf.no/wp-content/uploads/2016/09/iStock_67284239_XXXLARGE-resize-300x199.jpg" alt="Closeup shot of laptop with digitaltablet and smartphone on desk. Responsive design web page on their screen. Modern devices on desk at office." width="300" height="199" /></a> Closeup shot of laptop with digitaltablet and smartphone on desk. Responsive design web page on their screen. Modern devices on desk at office.[/caption]

    On the page this is getting printed as text:
    [caption id="attachment_685" align="aligncenter" width="300"]
    https://higraf.no/wp-content/uploads/2016/09/iStock_67284239_XXXLARGE-resize-300x199.jpg
    [/caption]
    Closeup shot of laptop with digitaltablet and smartphone on desk. Responsive design web page on their screen. Modern devices on desk at office.

    Tried disabling plugins and that did not solve the problem. I guess there are some troubles with the functions.php or another functions. Any ideas where I should take a look?

    You can see example page here: https://higraf.no/nyheter/hva-er-en-god-annonsetekst/

    Looking forward to hear from you,

    • This topic was modified 8 years, 5 months ago by higraf.
    • This topic was modified 8 years, 5 months ago by higraf.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Yeah I’d swap out your theme with one of the defaults and see if they work then.

    If they do, activate your theme again and then delete everything in functions.php, and see if it works then (this can be time consuming if your theme is calling functions that are defined in functions.php though).

    If you see the captions working again, add your code back piece by piece until you find the culprit.

    Thread Starter higraf

    (@higraf)

    Removed all the CSS, and problem is still the same.

    Removed everything in functions.php, and problem is still the same.

    Removed JS from header, and problem is still the same.

    Removed almost everything in footer.php, and problem is still the same.

    I am down to this:

    <div class="entrybody">
                            <div class="col-md-12 centertext">
                            	<h1 class="entrytitle luftopp nomarginbottom centertext"><?php the_title(); ?></h1>
                            	<span class="entry-date centertext">Av <strong><?php the_author(); ?></strong> <?php echo get_the_date(); ?></span>
                            </div>
                            <div class="col-md-1"></div>
                            <div class="col-md-10 luftned">
                                <div class="littluft luftned10 entrytext centertext">
                                    <?php 
                                        // Fetch post content
                                        $content = get_post_field( 'post_content', get_the_ID() );
                                        
                                        // Get content parts
                                        $content_parts = get_extended( $content );
                                        
                                        // Output part before <!--more--> tag
                                        echo $content_parts['main'];
                                    ?> 
                                </div>
                                <div class="littluft">
                                    <?php 
                                        // Output part after <!--more--> tag
                                        echo $content_parts['extended'];
                                    ?>
                                </div>
                            </div>
                            <div class="col-md-1"></div>
                        </div>

    Do you see an error in this code?

    Thank you for helping me out,

    Thread Starter higraf

    (@higraf)

    Problem solved by writing the following instead:

    <div class="littluft luftned10 entrytext centertext">
         <?php 
             // Fetch post content
    	$content = get_post_field( 'post_content', get_the_ID() );
    									
            $content = apply_filters('the_content', $content);
                                        
            // Get content parts
            $content_parts = get_extended( $content );
                                        
           // Output part before <!--more--> tag
           echo $content_parts['main'];
          ?> 
    </div>
    <div class="littluft">
        <?php echo $content_parts['extended']; ?>
    </div>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Caption is not being formatted correctly’ is closed to new replies.