• Hi all,

    <?php
    $loop = new WP_Query("p=272&post_type=HoverImage&post_status=publish");
    echo $loop->the_post();
    <center><?php echo '<img src="'.get_field('normal_image',get_the_ID()).'"/>';
    ?></center>
    <?php
    if(hover){
    //echo '<img src="'.get_field('hover_image',get_the_ID()).'"/>';
    }
    ?>

    this is my code i am viewing the image from custom field , now i want another image while hover the image.
    inside “if()” what condition should be put?? if any help provide it’ll helpful for me.
    Thanks sallu.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Firstly, this post should probably be moved, as this isn’t really a request or feedback. One of the mods here will be able to help with that.

    For your problem, you can’t do hover effects with PHP. PHP is a server-side only language, so it doesn’t have any ability to interact with a browser like that.

    To do a hover like that you’d need to have either CSS, JavaScript, or a mix of the two.

    Thread Starter msbsally

    (@msbsally)

    @catacaustic

    First of all thanks to look into my question. I am changing html template to wp site so i have a request that while hovering on a image which bring from custom field should be changed. how do i do this?

    Thanks Sallu.

    As I said, use CSS, JavaScript or a mix of both depending on how you want it set up. There’s (literally) 1,000’s of tutorials, code snippets and information sites out there, so do a bit of research and see what method suis your own purpose. Just remember that PHP can’t do the effect (you’ll need CSS or JS), but it can set up the HTML that’s needed by which ever system you choose.

    Thread Starter msbsally

    (@msbsally)

    Thanks,

    Sallu

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom post problem’ is closed to new replies.