Support

Account

Home Forums Backend Issues (wp-admin) Page Link – get parent page data

Solving

Page Link – get parent page data

  • Hello,

    I have 2 pages, pageA and pageB

    pageA has a link custom field that links to pageB

    1. Is there any way for pageB to detect that it is being linked to from pageA so if can provide a link back to pageA (without having to use the another link custom field)?

    1. In addition to doing question 1, can pageB also detect all other custom fields in page1 and use them in its template

    • feyfey

    • January 24, 2019 at 7:47 am

    Hi,

    (The solution below is for front-end page use)

    If your custom field on page A (which contain the link to the page B) is not a repeater field you can simply use the ‘WP_Query‘ with meta_query on PageA to get all page where you custom field is equal to you current page link.

    Because the query will return page IDs, you can get all the pageA cutom field values.

    Hope it’s help. ASk if you need more details.

  • Thanks feyfey, can you show me where I can get a sample of that query? (the meta query one)

  • hello, I have been posting this everywhere, i cant get the quest to work

    `$args = array(
    ‘numberposts’ => -1,
    ‘post_type’ => ‘product’,
    ‘meta_key’ => ‘page_link’,
    ‘meta_value’ => $post->ID
    );

    $loop = new WP_Query( $args );

    //echo $loop->request;

    while ( $loop->have_posts() ) : $loop->the_post();

    the_title();

    endwhile;

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.