• Resolved José Antonio Pons

    (@japonsm)


    Hola!

    How text should be concatenated to the code added in the category template:

    <?php if(function_exists(‘rdv_category_image’)){ rdv_category_image(); } ?>

    … so that it shows up on the page next to the image?

    e.g. “Sponsored by” [IMAGE]

    Thank you,

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author rdvinfotech

    (@rdvinfotech)

    Hi @japonsm

    Thanks for reaching out. You can use the template tag just after the text.

    Thread Starter José Antonio Pons

    (@japonsm)

    Hi, thanks for your support.

    I have inserted the code with this format:
    <?php if(function_exists(‘rdv_category_image’)){
    echo ‘Patrocinat per ‘;
    rdv_category_image(); } ?>

    The text appears correctly before the image. However, this text also appears on category pages where no image is defined.

    With this code I’m trying to detect if the function returns an image so I can discard the text when it’s not needed:

    <?php if(function_exists(‘rdv_category_image’)){
    if ( true === rdv_category_image() ) {
    echo ‘Patrocinat per ‘;
    rdv_category_image();
    }
    } ?>

    I have also tried this other way:

    <?php if(function_exists(‘rdv_category_image’)){
    if ( true === rdv_category_image() ) {
    echo ‘Patrocinat per ‘ . rdv_category_image();
    }
    } ?>

    In both cases the image is displayed but the text is not displayed.

    How could I detect if the function returns an image so that I can discard the text when it’s not needed?

    Thanks in advance.

    Plugin Author rdvinfotech

    (@rdvinfotech)

    Hi @japonsm

    You can use this function rdv_category_image_url() to detect the image or image URL. Please check these two examples.

    <?php if( function_exists('rdv_category_image_url') && !empty(rdv_category_image_url()) ){
        echo 'Patrocinat per <img src="'.rdv_category_image_url().'">';
    } ?>
    <?php if( function_exists('rdv_category_image') && !empty(rdv_category_image_url()) ){
        echo 'Patrocinat per ';
        rdv_category_image();
    } ?>
    Thread Starter José Antonio Pons

    (@japonsm)

    The proposed solution works perfectly.

    Thank you,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Include text in code’ is closed to new replies.