Forums

Custom field based on page parent (4 posts)

  1. IslandGirl
    Member
    Posted 1 year ago #

    I've been working on this all afternoon, and I'm brain dead due to it. Abnd the search function in the forum doesn't seem to be working.

    I have a Page template that is used for "Special Promotions" and each hotel has its own Page with subpages, and one of them is called "Special Promotions".

    Now there is a category called "Special Promotions" with several subcategories. I have added a custom field called "special_location" and have entered the ID of the hotel.

    I've used and pulled in with a specific value in the past, but this will be a variable which I am really having problems with.

    Any suggestions and help is greatly appreciated.

    Chris

  2. krembo99
    Member
    Posted 1 year ago #

    I am sorry, But I really did not understood the problem.
    I mean, You described the hirarchy of your web , but I couldn't find a description of what you are trying to achive .

  3. IslandGirl
    Member
    Posted 1 year ago #

    I found the solution on how to pull the custom field value in as a variable via a custom Page template. And you are right, I didn't explain myself well so I had reposted the question under "Passing Variable to wpostmeta.meta_value".

    I'll admit the problem I was having was finding the right value to pass the page id to the query. That page id is stored as the value in the posts.

    If the Page ID is 297 that number is entered in the custom field value, and the query goes an looks for all of the posts that have 297. And another page might have 303 with that value entered into the custom field.

  4. krembo99
    Member
    Posted 1 year ago #

    Well.. I have to say, I have answered a lot of problems here on the form, but never had such a difficulty understanding exactly what is the problem...
    After reading both your posts, I think I understood. Not sure, But I'll try.
    Why not just check if a custom field exist at the template level ?
    and filter those posts there ?
    You can use :
    $mykey_values = get_post_custom_values('my_key');
    to get the values
    or an IF statement to check if the key exist and print the post :

    ?php $key="mykey";
     get_post_meta($post->ID, $key, true);

    then if key exist do whatever you want to do.

    But like I said, I am not at all sure I understood the problem

Topic Closed

This topic has been closed to new replies.

About this Topic