badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

show caption of featured image on post/page

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #80907
    Roberto
    Participant

    i’dd show caption of featured image on post/page.
    Please, help me.

    #80937
    Roberto
    Participant

    i done it adding in /template-parts/content.php in row 36:

    <?php
    $get_description = get_post(get_post_thumbnail_id())->post_excerpt;
    if(!empty($get_description)){//If description is not empty show the div
    echo ‘<div class=”featured_caption”>’ . $get_description . ‘</div>’;
    }
    ?>

    #80994

    Hi Roberto,

    Did the code that you added worked? We think it doesn’t work.

    Please remove those added code then on line no: 34. you will find the below code.

    </figure><!-- .post-featured-image .page-single-img-wrap -->

    Now replace the above mentioned code with the below provide code.

    <figcaption class="featured-image-caption"><?php echo get_the_post_thumbnail_caption(get_the_ID()); ?></figcaption>
    </figure><!-- .post-featured-image .page-single-img-wrap -->

    after replacing the code save the file and please go to ‘Appearance > Customize > Additional CSS’ and paste the below Custom CSS Code.

    .post-featured-image.page-single-img-wrap {
    	overflow: hidden;
    }
    .post-featured-image.page-single-img-wrap .featured-image-caption {
    	position: absolute;
    	left: 0;
    	right: 0;
    	bottom: 0;
    	padding: 50px 25px 15px;
    	color: #ffffff;
    	background: linear-gradient(rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.5));
    }
    @media (max-width: 767px) {
    	.post-featured-image.page-single-img-wrap .featured-image-caption {
    		padding-left: 15px;
    		padding-right: 15px;
    	}
    }

    Thanks

    #81003
    Roberto
    Participant

    my code works but your Is graphically better. but it no works so.
    I modify so:

    
    <?php
    $get_description = get_post(get_post_thumbnail_id())->post_excerpt;
    if(!empty($get_description)){//If description is not empty show the div  					
    ?> 
    <figcaption class="featured-image-caption"><?php echo esc_html ($get_description);?></figcaption>
    <?php } ?>
    </figure><!-- .post-featured-image .page-single-img-wrap -->		
    <?php } ?>
    
    .post-featured-image.page-single-img-wrap .featured-image-caption {
    	position: absolute;
    	left: 0;
    	right: 0;
    	bottom: 0;
    	padding: 7px 25px 7px;
    	font-weight:bold;
    	font-style:italic;
    	color: #ffffff;
    	background-color: black;
    	opacity: 70%
    }
    @media (max-width: 767px) {
    	.post-featured-image.page-single-img-wrap .featured-image-caption {
    		font-size:80%;
    		text-align:center;
    		padding-left: 15px;
    		padding-right: 15px;
    	}
    }
    }
    #81019

    Ok the code we provided was just for the Featured Image caption so the only text set on Caption field will be displayed. The description won’t be displayed by that code.

    Anyways its great that your code worked but you have added an extra ‘}’ (curly braces) at the end. If you are going to add some additional Custom CSS code after it then the code won’t work because of that extra curly braces.

    Thanks

    #81024
    Roberto
    Participant

    A last question: how can i override inc folder in child theme?

    #81044
    Roberto
    Participant

    the files in inc/ folder have not !function_exists

    #81122
    Roberto
    Participant

    Please help me

    #81151

    Just create the ‘inc’ folder on the Child Theme. and to link with the php files just use the code on main function.php file as mentioned below.

    require get_stylesheet_directory() . '/inc/abc.php';

    Thanks

    #81157
    Roberto
    Participant

    No works
    i put:
    require get_stylesheet_directory() . '/inc/newscard-widgets.php';

    i’ve error.

    i want translate the words “populair”, “commented”, “recent” in /inc/newscard-widgets.php

    #81314
    Roberto
    Participant

    are you there?

    #81380

    Hi Roberto,

    Just to translate those text it is not necessary to create child theme.
    You can create a .po, .mo file to translate those text from the help of this plugin.

    Thank you!

    #81383
    Roberto
    Participant

    your widget no use WordPress languege but it saved in PHP file in /inc/

    #82460

    Sorry for late reply. We missed your reply.
    What are you trying to say? Can you please clarify?

    Thank you!

    #82465
    Roberto
    Participant

    i fixed with plugin.
    thank you very much. 🙂

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.