Support » Fixing WordPress » Image caption

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael


    Forum Moderator

    please re-post the code, and mark the code according to the forum guidelines

    inkthemes_main_image(); seems to be a custom function of your used theme;

    what theme are you using?

    what is the code behind this function?

    you might need to post a link to your site to illustrate the image and text html in the context of the existing css.

    for pure formatting or css questions, please ask at a css forum like

    <?php while (have_posts()) : the_post(); ?>
    <a href="<?php the_permalink(); ?>"> <?php echo inkthemes_main_image(); ?> </a></a>
    <?php endwhile; ?>

    Themia Lite, inkthemes main image is a function that calls the posts’s main image.

    function inkthemes_main_image() {
        global $post, $posts;
        //This is required to set to Null
        $id = '';
        $the_title = '';
        // Till Here
        $permalink = get_permalink($id);
        $homeLink = get_template_directory_uri();
        $first_img = '';
        $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
        if (isset($matches [1] [0])) {
            $first_img = $matches [1] [0];
        if (empty($first_img)) { //Defines a default image
        } else {
            print "<a href='$permalink'><img src='$first_img' width='140px' height='208px' class='postimg wp-post-image' alt='$the_title' /></a>";


    Forum Moderator

    the posted code simply pulls the first image tag from the post’s content, which makes it virtually impossible to get the corresponding image caption.

    however, the theme also seems to use the ‘featured image’ if it is used;
    this would make it easier to show the image caption.

    then you will need to replicate the html and css structure from your example site.

    I used other css caption and it worked!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Image caption’ is closed to new replies.