Support » Themes and Templates » PHP question, probably simple to experienced users

  • 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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.

    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(“,“, 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

    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 = "";
    elseif( is_page(15) )
       $imageLoc = "";
    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.

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP question, probably simple to experienced users’ is closed to new replies.