WordPress.org

Ready to get started?Download WordPress

Forums

PHP question, probably simple to experienced users (5 posts)

  1. PinkishHue
    Member
    Posted 2 years ago #

    I'm trying to display the value from a custom field within a php statement in a custom template, I have a feeling it's something like this but this doesn't work:

    <?php get_image_feed_list(". echo get_post_meta($post->ID, 'RSS-URL', true ); .", 10, "ImagesList", 1); ?>

    Can anyone help me with this?

  2. jmag
    Member
    Posted 2 years ago #

    I am not entirely sure I understand what you want to do. One problem I can see right away is that the first 1/2 of your argument is a string when you are trying to use a function as an argument. You need to remove the quotes around it to get the argument function's result passed to the main function.

    Not as much help as you probably wanted but should help some.

  3. PinkishHue
    Member
    Posted 2 years ago #

    Hi, thanks for the reply :) Apologies if my explanation wasn't clear, I'm not very proficient with PHP and had tried to knock something together myself which seemingly was wrong! I will explain more clearly...

    I'd like to have a custom template with this code in:

    <?php get_image_feed_list("http://www.example1.com/rss,http://www.example2.com/rss2", 10, "myImagesList"); ?>

    And have the URL part generated by a custom field on the post/page the custom template has been assigned to.

    Hopefully that is simple to achieve? I have done something similar before but the custom field was not put within a section of php so I was able to figure it out then :)

    Thanks again for any advice

  4. jmag
    Member
    Posted 2 years ago #

    Are there a predefined number of URL's? If so, the easiest way would be to use a conditional based on the page id.

    if( is_page(12) )
       $imageLoc = "http://www.example1.com/rss";
    elseif( is_page(15) )
       $imageLoc = "http://www.example2.com/rss";
    get_image_feed_list($imageLoc, 10, "myImagesList");

    Hope this is helpful. You can also use the page title or page slug, if enabled, instead of the page id. Also double check that the plugin that uses this function is properly installed.

  5. PinkishHue
    Member
    Posted 2 years ago #

    I would have trouble using the page ID or slug because the URL is from an external site, but I have managed to achieve what I needed as follows (in case anyone else is interested)

    <?php $key="rssfeedurl"; // the custom field
    $rssurl = get_post_meta($post->ID, $key, TRUE);
    if ($rssurl != "" ) {
    get_image_feed_list("$rssurl", 10, "ImagesList", 1);
    }
    ?>

    Thanks anyway for your help, much appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.