Support

Account

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(); ?>