Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

What is the best way of getting a custom field value from a page which is not the one currently displayed? I know the title of the page i want to get custom field value from, but not the pageID.

Thanks!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Use:

$meta = get_post_meta($id, $key, $single);

With $single set to true if you don't want WP to return an array for unique meta keys.

share|improve this answer
    
I don´t have the post id available. I only know the title of the page –  Espen Arnoy Nov 1 '10 at 12:26
    
Is there a way of submitting a page/ post title and get the ID in return? –  Espen Arnoy Nov 1 '10 at 12:29
    
Not short of querying the db directly. (There's a function to get the post by url, though.) You can see the ID by editing the post - it appears in the url. –  Denis Nov 1 '10 at 12:33
1  
There is get_page_by_title() function, not sure if it works for posts (from brief look at code it takes $post_type argument so might). –  Rarst Nov 1 '10 at 13:34
    
Oh woops. I stand corrected. :-) –  Denis Nov 1 '10 at 15:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.