Support

Account

Home Forums General Issues How to add field in file_get_html

Solved

How to add field in file_get_html

  • Hello,
    I am trying to add a field in this code but it’s not working, can anyone help me with this?

    <?php
    include ("simple_html_dom.php");
    $name = get_post_meta($post->ID, 'company', true);
    $html = file_get_html("https://other-website-url.com/company/.$name.");
    ?>
  • I can’t find any information for a function file_get_html() what is this function?

  • Could you please confirm that I have the correct code for adding a custom field to this code?

  • This:

    $name = get_post_meta($post->ID, 'company', true);

    Should hold the value of an ACF-based or native meta key called ‘company’ if the post ID is being pulled. If it’s not working, I would try to echo out $post->ID to make sure it’s correct, if it is, double check the field name. If echo $name works, I’d look at the rest of your code as it’s not possible to know what’s in the include or what else is going on.

    Think this:

    $html = file_get_html("https://other-website-url.com/company/.$name.");

    Is where your error is, for example. Likely should be something like:

    $html = file_get_html("https://other-website-url.com/company/". $name);

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

You must be logged in to reply to this topic.