Support » Fixing WordPress » URL from a custom field to get_meta_tags function

  • Resolved astair


    I’m working on a showcase site with ratings. I’d like to add a description of each site automatically. This can be done with get_meta_tags() function. And as far as I know, I’m not able to use PHP in custom fields(?)

    It’s easy when there’s only one certain website to fetch the description from:

    <?php $tags = get_meta_tags(‘;);
    echo $tags[‘description’]; ?>

    But in this case I want to fetch them automatically from each site and the function is placed within my single.php file.

    I’ve got a custom field named URL with a website url as value (I use it for other purposes too). So, I would like to have the get_meta_tags function grab the website’s url from the custom field.

    I’m a rookie with anything concerning PHP but I’ve tried several ways to achieve my goal. I’ve read a few tutorials and manuals but each of them have examples only of fetching the tags from one specific url.

    Is there a way to run some function inside the get_meta_tags() function or do I need to go even further somehow?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Might want to review Using_Custom_Fields and then go from there…

    Thread Starter astair


    Thanks MichaelH but I have tried to figure it out there as well. The problem is that I don’t seem to find a way to make the get_meta_tags function to read from i.e. WP’s get_post_meta($post->ID, $url, $single = true) so that it would know where to fetch the description from. I keep getting an error saying:

    get_meta_tags(get_post_meta($post->ID, $url, $single = true)) [function.get-meta-tags]: failed to open stream: No such file or directory in **path to my single.php**

    where get_post_meta($post->ID, $url, $single = true) is whatever I’ve put inside the get_meta_tags function. As I said, I’m a rookie with PHP, so maybe someone could tell me how to create a valid function inside the get_meta_tags function.

    Based on the above..

    <?php $tagurl = get_post_meta($post->ID, YOURCUSTOMFIELDNAME, true);
    if($tagurl) : $tags = get_meta_tags( $tagurl ); echo $tags['description'];
    else : echo 'no tag url';

    *I think* 🙂

    Thread Starter astair


    Absolutely beautiful! Thank you t31os_.

    No problem.. 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘URL from a custom field to get_meta_tags function’ is closed to new replies.