Site logo

Archived topic

Hook works on Pages but not on Archive

4 replies · Started by Benedikt on February 26, 2019

Viewing posts 1–5 of 5

Hey there,

my hook work's at all Pages but not on the Archive page.

Hook Display rules: Front Page, Blog, Archive.
Hook location: after_header, php is checked.
Priority: 10.

I've also tried to make a special hook for Archive page with the same code but different name giving.

here's my code:

<?php
// define parent element variables
$sliderelements = get_field('headerslidernews');

// define background image variables
$bgimage = get_field('hintergrund_bildnews');
$bgimage_size = 'large'; // (thumbnail, medium, large, full or custom size)

// define autoplay via ACF
$sliderimage_autoplay = get_field('autoplaynews');
$slider_nav = get_field('slider_navigationnews');

?>
<?php // check if the repeater field has rows of data
if( have_rows('headerslidernews') ): ?>
	<div id="home_slider" class="<?php echo $slider_nav; ?>">
		<div class="main-carousel headerslider grid-container container grid-parent" data-flickity='{
				"cellAlign": "center",
				"contain": true,
				"pageDots": true,
				"prevNextButtons": false,
				"wrapAround": true,
				"autoPlay": <?php echo $sliderimage_autoplay; ?> }'>
		 <?php // loop through the rows of data
     while ( have_rows('headerslidernews') ) : the_row();
		 	// define image variables
	 		$sliderimage = get_sub_field('bildnews');
	 		$sliderimage_size = 'large'; // (thumbnail, medium, large, full or custom size)
	 		// define link
	 		$sliderlink = get_sub_field('linknews');
		 ?>
		    <div class="carousel-cell">
					<div class="carousel-cell-textbox">
						<h2 class="slider-titel">
							<?php the_sub_field('titelnews');?>
						</h2><!-- slider-titel -->
						<p class="slider-text">
							<?php the_sub_field('textnews');?>
						</p><!-- slider-text -->

						<?php // Break up link array
						if( $sliderlink ):
							$link_url = $sliderlink['url'];
							$link_title = $sliderlink['title'];
							$link_target = $sliderlink['target'] ? $sliderlink['target'] : '_self';
							?>
							<div class="link-button_slider link-button">
								<a class="read-more button" href="<?php echo esc_url($link_url); ?>" target="<?php echo esc_attr($link_target); ?>"><?php
									if( $link_title ):
										echo esc_html($link_title);
									else:
										_e('Read More' , 'a1startup');
									endif; ?>
								</a>
							</div><!-- link-button -->
						<?php endif; // $sliderlink ?>
						</div>

							<div class="sliderimage">
			        	<?php echo wp_get_attachment_image( $sliderimage, $sliderimage_size ); ?>
							</div><!-- sliderimage -->
			   </div><!-- carousel-cell -->
			<?php endwhile; ?>
	  </div><!-- main-carousel headerslider -->
	</div><!-- home_slider -->
<?php endif; // $sliderelements ?>

<style type="text/css">
	#home_slider {
		background-image: url("<?php echo $bgimage; ?>");
	}
</style>

Hi there,

i am not sure how ACF Fields could be called for the Archive page. Where would these fields be populated?

hi @david,

These fields will be populated in the backend where you can set up a slider for the frontend.

hi @david,

These fields will be populated in the backend where you can set up a slider for the frontend.

This archived topic is closed to new replies.