Site logo

Archived topic

Hook only for post

9 replies · Started by Fulvio on July 6, 2017

Viewing posts 1–10 of 10

I inserted 2 line of php in Hook: After Content

<!-- inizio rating -->
<?php if ( is_single() ) { 
    echo do_shortcode("[elementor-template id='16040']");
} ?>
<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
<!-- fine rating -->

this is for add a rating to post.

the first is a short code of elmentor, and this is visible only only in blog post

the second is the short code of wp-post rating and this is visible

but this code Is visible both in blog posts and in articles.

you can see a blog post:
https://www.sarao.it/business-model-cose-si-realizza/

and this is an article:
https://www.sarao.it/progettazione-ecommerce/

Or we show shorcode and rating both in posts or in articles or in post blogs, but half way does not make sense.

Do you have a solution?

Ps I have separated elmentor's shortcode and rating because unfortunately by entering the shortcode of the rating inside the elmentor template i got an error, and I want the rating to have the box with the explanation text and the blue background color

this is what i need:

what  i need

this is what i got on blog post

This is what i got on blog post

This is what i got on articles

This is what i got on articles

You might need to ask the ratings plugin author if you can display the rating using a shortcode.

Then you could add it into your Elementor library item directly, and only include the Elementor shortcode.

i tried to add the shortcode in elmentor
but whit the new elmentor 1.5 i got a problem, the rating score is only one for all the posts (befoore the relize of 1.5 all was correct, but in elmentor don't wanto to gave me suppot, they say is a plugin problem, maybe ys, but in 1.4 all was fine.

Ok tom, can you suggest me where put the php code (not in hook) in whitch file and how add a div whit the backgroud color as the pic i show you.

thanks

In order to place the ratings inside the blue background, they would need to exist in the library item.

Adjusting your code to show ratings on single posts only would look like this:

<!-- inizio rating -->
<?php if ( is_single() ) { 
    echo do_shortcode("[elementor-template id='16040']");

    if ( function_exists( 'the_ratings' ) ) {
        the_ratings();
    } 
} ?>
<!-- fine rating -->

Tom, thanks a lot for your reply.
now is visible only in blog post as I need, thanks

but the rating is out the blu elmentor template, have you any other suggestion?

thanks
Fulvio

In order to get it in the Elementor template, it would have to be a shortcode that you enter into the template itself.

I told you, i did it, but something go wrong.

there is a possibility to add this box whitout ousing elmentor's tempalte?

Sorry but if i insert a DIV and HTML whit beckground color and <p> i got some error or is possible?
someting like:

<div="background-color:blu;">

<h3>This is a heading</h3>
<p>This is a paragraph.</p>

Yep, you could do this:

<div class="blue-box">
    Content in here
</div>

Then add CSS for it:

.blue-box {
    background-color: blue;
    color: white;
    padding: 15px;
}

Then just update the colors.

Thanks a lot Tom, this fix my problem.
Thanks

I used this:

Css:

.rating-box {
    background-color: rgba(181,226,226,0.67);
    color: black;
    padding: 15px;
}

Hook - after content

<!-- inizio rating -->
<div class="rating-box">

<?php if ( is_single() ) { 
    echo do_shortcode("<p><b>Vota l'Articolo</b><br>
Lascia un voto da 1 a 5 stelle per indicare a chi arriverà dopo di te la qualità di questo articolo, naturalmente spero in un voto alto ;-)</p>");

    if ( function_exists( 'the_ratings' ) ) {
        the_ratings();
    } 
} ?>
</div>
<!-- fine rating -->

thanks a lot

Awesome! No problem :)

This archived topic is closed to new replies.