Responsive WordPress Slider - Soliloquy Lite
[resolved] PHP code with custom post meta (3 posts)

  1. Bambalazs
    Posted 3 years ago #

    Hello. First of all, thank you for this great plugin. :)

    My problem is that I'm beginner in php. I have no clue how to implement custom post meta value inside the php single qoutes.

    This is the custom post meta (gallery is ID of Soliloquy):

    <?php get_post_meta($post->ID, 'gallery') ?>

    And this is the original php code:

    <?php if ( function_exists( 'soliloquy_slider' ) ) soliloquy_slider( '248' ); ?>

    I created this, but it is not working because single quotes.

    <?php $soliloquy = get_post_meta($post->ID, 'gallery') ?>
    <?php if ( function_exists( 'soliloquy_slider' ) ) soliloquy_slider( '$soliloquy' ); ?>

    Could you help me to get working code? :)


  2. Thomas Griffin
    Plugin Author

    Posted 3 years ago #

    Here is what you need:

    <?php $soliloquy = get_post_meta( $post->ID, 'gallery', true ); ?>
    <?php if ( function_exists( 'soliloquy_slider' ) ) soliloquy_slider( $soliloquy ); ?>

    That should get you working correctly. You need the true as the last parameter of get_post_meta in order to return a single value instead of the default array value from the database. Also, you don't need quotes around variables when you are passing them as a function parameter.

    If you dig Soliloquy, a 5-star rating would rock! :-)

  3. Bambalazs
    Posted 3 years ago #

    Thank you, it works.

    You'll get five stars, I'm sure. ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic