Support

Account

Home Forums Front-end Issues Getting custom field value from another page

Unread

Getting custom field value from another page

  • I have created a Custom Field named ‘slides_number’. I would like to get the value in my homepage but this page works differently so I don’t have a page created in admin panel for home. So I have set the ‘slides_number’ custom field to a different page with ID=194.

    Then, in mi view, I show a slider which needs to take the value f ‘slides_number’ to know how many posts to show. I do this:

    $slides_number = get_field('slides_number', 194);
          // Get the latest highlight news
          $args = array(
            'post_type' => 'post',
            'posts_per_page' => $slides_number,
            'meta_query' => array(
              array(
                'key' => 'sfeatured',
                'value' => 'super-sfeatured',
                'compare' => '='
              )
            ),
            'orderby'=>'date',
            'order'=>'DESC'
          );
          $the_query = new WP_Query( $args );

    But ‘slides_number’ doesn’t get any value. What am I missing?

Viewing 1 post (of 1 total)

The topic ‘Getting custom field value from another page’ is closed to new replies.