• Resolved Palani Rajagopal

    (@rajagopalpalani)


    write a hook to add code, which will delete the existing content in any page after 20 seconds, when refreshing the page, same content to be displayed and delete process should be continue.

    Recently i faced one interview for wordpress developer. I am not able to understand this question. Can anyone please explain above question?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The hook would have to add a javascript code block to the page. Javascroipt is required since the issue is about the browser display (in this case time), this can’t be done from the server.

    Basically they’re asking you to create a little piece of code that displays content for 20 seconds, and then it should be removed. Also they want it done via a hook.

    For example:

    add_action( 'wp_footer', 'remove_content_timer' );
    function remove_content_timer() {
    	?>
    	<script type="text/javascript">
    
    	setTimeout(function() {
    		// run the necessary javascript to remove the content
    	}, 20000); // run function after 20000ms
    
    	</script>
    	<?php
    }

    Thread Starter Palani Rajagopal

    (@rajagopalpalani)

    Tormorten

    Superb. Thank you so much

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘About hooks’ is closed to new replies.