Before you ask please READ THIS

Insert RevolutionSlider PHP code

CFPCFP
in Photon Posts: 122
Where can I insert (in the php) this code to change the image to a slider?
<?php putRevSlider("slider1") ?> but instead of "slider1" there has to be a get post id.

Comments

  • AirAir
    Posts: 10,970
    Like I asked in your original post- where you want to add it exactly(link to exact page).
    Air said: Please move second question to new topic and give more details(where you want this for example).
    With kind regards.
  • CFPCFP
    Posts: 122
    In a blogpost, instead of a blogpost image.
  • AirAir
    Posts: 10,970
    I believe you can try this as as your first approach:
    File single.php line ~28, replace <?php a13_top_image_video(); ?> with your code for slider.

    With kind regards.
  • CFPCFP
    edited April 2016 Posts: 122
    Ok, thank you. But I need the post-ID inside e.g. (but this does not work)
    <?php putRevSlider("<?php the_ID(); ?>") ?>
    Post edited by Air on
  • AirAir
    Posts: 10,970
    You insert there ID of your slider, not ID of your post(what your code does now).

    With kind regards.
  • CFPCFP
    Posts: 122
    Thats true. I will call the post ID.
    The RevSlider supports - in this case - only the name of a slider. But if I use a a name in the single.php it will call the same slider on each post. So I try to get the post ID to give each slider different ID (name) so that it calls the slider with the same "name" like the post-id. So I have to rename each slider exact like the post ID to show the right one.

    But in my code it shows me a php error. And I have no detailed knowhow in php to get this done.
  • AirAir
    Posts: 10,970
    Sorry, can't help you with that(your code is wrong btw, you are embeding PHP tags wrong way). However you can do trick. In Screen options enable Custom Fields and do something like that:
    image

    Next read value of this field as explained here https://codex.wordpress.org/Using_Custom_Fields

    So you Will have something like that:
    <?php putRevSlider( get_post_meta(get_the_ID(), 'slider_id', true) ) ?>

    With kind regards.
    ss-2016-04-13_11-46-26.png
    1393 x 190 - 7K
  • CFPCFP
    edited April 2016 Posts: 122
    Perfect! Ok, a little "if/else" - but it works!

    For those who are interested here is the code:
    
    		<?php
                        $var = get_post_meta(get_the_ID(), 'slider_id', true);
                        
                        if (empty($var)) {
                        a13_top_image_video();
                        }
                        
                        elseif (isset($var)) {
                        putRevSlider( get_post_meta(get_the_ID(), 'slider_id', true) );
                        }
                   ?>
    
    Post edited by Air on
  • AirAir
    Posts: 10,970
    Very nice!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion