Fetching text field from the node I am working on flex slider module and I want to add one button in caption so for that I have added one field in content type with Machine name: field_image_url and Field Type: text.

Now I am changing in core file of the module to fetch that URL into the front end.For that code is below:

    &lt;?php
    /**
     * @file
     * Default output for a Flex Slider node.
    */
    ?&gt;
    &lt;div class="flex-nav-container"&gt;
      &lt;div class="flexslider-content flexslider clearfix" id="flexslider-&lt;?php print $id; ?&gt;"&gt;
        &lt;ul class="slides"&gt;
        &lt;?php foreach($items as $item) : ?&gt;
          &lt;li&gt;&lt;?php print render($item); ?&gt;
            &lt;?php if(!empty($item['#item']['title']) || !empty($item['#item']['alt'])) : ?&gt;
             &lt;div class="flex-caption"&gt;
             &lt;h3&gt;&lt;?php print $item['#item']['alt'];?&gt;&lt;/h3&gt;
             &lt;p&gt;&lt;?php print $item['#item']['title']; ?&gt;&lt;/p&gt;
             &lt;?php if(isset($node-&gt;field_image_url)): ?&gt;
                &lt;a href="&lt;?php print render ($node-&gt;$field_image_url); ?&gt;" class="btn btn-theme"&gt;Learn More&lt;/a&gt;
             &lt;?php endif; ?&gt;
             &lt;/div&gt;
            &lt;?php endif; ?&gt;
          &lt;/li&gt;
        &lt;?php endforeach; ?&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;/div&gt;


I know I am making some mistake as I am very new to drupal development.

     &lt;?php if(isset($node-&gt;field_image_url)): ?&gt;
        &lt;a href="&lt;?php print render ($node-&gt;$field_image_url); ?&gt;" class="btn btn-theme"&gt;Learn More&lt;/a&gt;
     &lt;?php endif; ?&gt;


Above code is for fetching URL.It is not giving me any error, but it is also not showing me the button.I have already entered URL for one slide.

Where am I lacking ?

Edited :

I want to also mention that Slider is on front page and there is an article content just below to the slider.

I have given node path to the front page from the Configuration to show it on front page.

So now, If I do 

     &lt;?php 
        if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) {
          // Get the nid
          $nid = arg(1);
          // Load the node if you need to
          $node = node_load($nid); print_r($node);
        }
     ?&gt;


It is giving me the node ID of the article.I want the node ID of the slider Image so that I can pull out the image URL field that I have added to the Slider Image Content type.

EDITED:

    &lt;?php
        //this code will load all nodes from your content type and then print them
        $node_type = "slider_image"; 
        $result = db_query("SELECT nid FROM node WHERE type = '%s' ", $node_type);
        $nodes = array();
        while ($obj = db_fetch_object ($result)) {
          $node = node_load($obj-&gt;nid);
          echo $node-&gt;field_image_url['und'][0]['value'];
          echo '&lt;br&gt;';
          $nodes[] = node_load($obj-&gt;nid);
        }
    ?&gt;


I have tried above code but it is giving me an error : 
Recoverable fatal error: Argument 2 passed to db_query() must be of the type array, string given, called in path to modules\modules\flexslider\theme\flexslider-container.tpl.php on line 19 and defined in db_query() (line 2345 of path to site\includes\database\database.inc).

So to resolve above error, I tried following code with help of this:

$result = db_query("SELECT nid FROM node WHERE type = ':type' ", array(':type' =&gt; $node_type));

But above code also gives me error : Fatal error: Call to undefined function db_fetch_object() in path to module\modules\flexslider\theme\flexslider-container.tpl.php on line 21
In general to get the value of field if the entity type is a node

$node = node_load($nid);
echo $node-&gt;field_image_url['und'][0]['value'];


or try to print the $node to figure out how to get it

echo '&lt;pre&gt;'; var_dump($node); var_dump($node-&gt;field_image_url); die;


in your situation try the next to figure out what is happen there

&lt;?php
$node_type = "slider_image";
$sql = db_query("SELECT nid FROM node WHERE type = $node_type");
$results = db_query($sql);
foreach($results as $row){
   $node = node_load($row-&gt;nid);
   echo $node-&gt;field_image_url['und'][0]['value'];
   echo '&lt;br&gt;';  
}
?&gt;