I would recommend using a shortcode, because its easy to use and at the same time efficient.
Below I have attached the code, how you can put your code into a shortcode.
the add_shortcode function is what you use when you want to create a shortcode.
To use it, you simply need to write [render_slider_shortcode] anywhere you want your slider to be displayed.
PS: There might be some error in the code which you gave. I coudnt test it on my site. But rest is fine. If you come accross any errors, make sure your code is getting proper values.
// display a sub field value
add_shortcode('render_slider_shortcode', 'renderSLider');
function renderSLider()
{
if ( is_page("Home") ) {
if( have_rows('slider') ): ?>
<div class="my-slider"><ul >
<?php
// loop through the rows of data
while ( have_rows('slider') ) : the_row();
$image=get_sub_field('image');
$title= get_sub_field('title');
$byline= get_sub_field('byline');
$link= get_sub_field('link');
?>
<li>
<div style="background-image: url(<?php echo $image; ?>); min-height: 600px; background-repeat: no-repeat; background-size: cover">
<h2><?php echo $title; ?></h2>
</h3><?php echo $byline; ?><h3>
<a href="https://wordpress.stackexchange.com/questions/217378/<?php echo $link ?>"></a>
</li>
<?php endwhile ?>
</div>
<?php
else :
// no rows found ?>
<?php
endif;
} else {
// This is not the blog posts index
}
?>
</li>
</div>
<?php
}