WordPress.org

Ready to get started?Download WordPress

Forums

Call NextGEN Gallery directly from template (3 posts)

  1. blogjunkie
    Member
    Posted 6 years ago #

    Hi guys, anyone know how to call NextGEN Gallery recent images directly from sidebar.php and home.php?

    I found this link (http://nextgen.boelinger.com/2007/05/24/new-widget-support/) but adding the below to my templates (and also without the variables) didn't work.

    $number_of_pic = '4';
    $Width = '160';
    $Height = '160';
    if (function_exists(’nggDisplayRecentImages’))
    { nggDisplayRecentImages($number_of_pic,$Width,$Height); }

    If anyone's figured this out I would really appreciate it. Cheers!

  2. frisco
    Member
    Posted 6 years ago #

    I was having the exact same problem, and your question gave me the answer, so maybe I can help you. 2 things to check:

    1) that you have the NextGen Gallery Widget activated in addition to the NextGen plugin. The template functions are in the widget, so even if you are not using sidebar widgets, you need the widget activated.

    2) looking at your code, the single quote character is different in your line that checks if the function exists. If you copied the code directly from the webpage and edited in something like Notepad, you don't have a single quote. You don't need to declare the variables, just enclose the values in the function call in single quotes.

    nggDisplayRecentImages('4','160','160);

    With those changes, it worked for me.

  3. obsediado
    Member
    Posted 5 years ago #

    /**
    * nggDisplayRecentImages($number,$width,$height,$exclude,$list)
    * Function for templates without widget support
    *
    * @return echo the widget content
    */
    function nggDisplayRecentImages($number, $width = "75", $height = "50", $exclude = "all", $list = "") {

    $options[1] = array('title'=>'',
    'items'=>$number,
    'show'=>'thumbnail' ,
    'type'=>'recent',
    'width'=>$width,
    'height'=>$height,
    'exclude'=>'all',
    'list'=>$list );

    EXAMPLE:

    <?php if (function_exists('nggDisplayRecentImages'))
    { nggDisplayRecentImages('6','160','80','all','');
    }
    ?>
    (number, width, height, exclude and list)

    OK?

Topic Closed

This topic has been closed to new replies.

About this Topic