Home Forums General Issues Get the field (url) in function.php – function fields_in_feed


Get the field (url) in function.php – function fields_in_feed

  • I have a custom field “site_link” which is of the type “Link to page or article”.
    I want to display this url in my RSS feed.
    I use the function in “function fields_in_feed” in function.php
    If I use:. get_field($post_id, “site_link”, true ) > it does not show me anything
    If I use: . get_post_meta($post_id, “site_link”, true) > it shows me a number but not a URL

    Do you have a solution

    Reminder of the base code “function fields_in_feed”:
    function fields_in_feed ($ content) {
    if (is_feed ()) {
    $ post_id = get_the_ID ();
    $ output = ”;
    $ output. = ”. get_post_meta ($post_id, “field”, true). </ P> ‘;
    $ output. = ‘</ div>’;
    $ content = $ content. $ output;
    return $ content;
    add_filter ( ‘the_content’, ‘fields_in_feed’);

    get_field('site_link', $post_id);

    The first argument for get field is the field name, second is the post ID, this is reverse of get_post_meta()

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

You must be logged in to reply to this topic.