Home › Forums › Front-end Issues › get page link query not working › Reply To: get page link query not working
solved my self just changed the field type to relation ship and return post id in and array of the page and then used this code just it case its useful to anyone
<?php
// get id of current page and store it in $pageid variable
global $post;
$pageid= $post->ID;
//query arguments
$args=
array(
'post_type' => 'features'
);
//set up query with arguments input
$query = new WP_Query( $args );
// run loop
if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>
<?php
$pagelink= get_field('pagelink');
// get_field(pagelink) returns page id selected in the pagelink field as array with 0 as the key and the page id number as the value, then we store it in pagelink variable
if($test[0] === $pageid){
//if the field pagelink is the same as pageid of current page then
if (get_field('alignment') === 'left' ) {
get_template_part('content','leftsided');
}
else if(get_field('alignment') === 'right' ) {
get_template_part('content','rightsided');
}
}
?>
<?php endwhile; endif; wp_reset_postdata(); ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.