• Hey Everyone….

    Shauno was a able to write a program that would allow me to recall top voted images to anywhere on my website. The only problem I have is where do I insert the program. He says to Copy and paste into your functions file: the only problem is that I dont know where the functions file is. Then he said paste this code anywhere you want to show your top images: <?php shaunos_awsome_top_images_i_should_really_consider_donating(10); ?> So I ask where in the visual template or the html template. And do I need a special php plugin to recall the function of the program.

    Shauno I know I have been picking your brain so I decided to post so anyone could try and help.

    Thanks

Viewing 15 replies - 1 through 15 (of 51 total)
  • The functions.php file is in your theme: wp-content/themes/your-theme-name/functions.php. If it isn’t there, just make one.

    You will need to past that other code into one or more of your theme’s php files: index.php, single.php, etc. They are in the same directory as functions.php.

    Thread Starter SlickVicENT

    (@slickvicent)

    posted in the following areas

    functions.php ( My Theme Functions )
    single.php ( My Single Post )
    and
    index.php ( My Main Index Template )

    I posted program at the very bottom and when I use the call to the function on my home page and I wasnt able to call my top rated images

    I’m assuming that the ‘program’ you are talking about looks something like this:

    function a_name(...) {
    
    }

    If so, paste that into functions.php and nowhere else.

    The other part should go into the theme files where you need it to go. I can’t tell you where that is.

    If its not working then you did it wrong or Shauno did it wrong. I can’t tell you which.

    It is going to be hard to help further without seeing the code. Use the pastebin.

    Thread Starter SlickVicENT

    (@slickvicent)

    HERES THE PROGRAM SHAUNO WROTE

    function shaunos_awsome_top_images_i_should_really_consider_donating($limit=10) {
    global $wpdb, $nggdb;
    $qry = 'SELECT pid, SUM(vote) AS total, AVG(vote) AS avg, MIN(vote) AS min, MAX(vote) AS max, COUNT(vote) AS num'; //yes, no joins for now. performance isnt an issue (i hope...)
    $qry .= ' FROM '.$wpdb->prefix.'nggv_votes';
    $qry .= ' WHERE';
    $qry .= ' pid > 0';
    $qry .= ' GROUP BY pid';
    $qry .= ' ORDER BY avg DESC';
    $qry .= ' LIMIT 0, '.$limit;
    
    $list = $wpdb->get_results($qry);
    
    foreach ($list as $key=>$val) {
    $val->image = nggdb::find_image($val->pid);
    
    /*
    //Uncomment this amazing piece of code to see all the magical attributes provided, free of charge, by NextGEN. Radical bro.
    print("<pre style='font-family:verdana;font-size:13;color:#000;z-index:99999;background:#ccc;'>");
    print_r($val);
    print("");
    */
    
    echo "<a href='";
    echo $val->image->imageURL;
    echo "' title='";
    echo $val->image->description;
    echo "'";
    echo $val->image->thumbcode;
    echo "'><img title='";
    echo $val->image->alttext;
    echo "' alt='";
    echo $val->image->alttext;
    echo "' src='";
    echo $val->image->thumbURL;
    echo "'";
    echo $val->image->size;
    echo " />";
    }
    }
    Thread Starter SlickVicENT

    (@slickvicent)

    posted in the following areas

    functions.php ( My Theme Functions )
    single.php ( My Single Post )
    and
    index.php ( My Main Index Template )

    I posted program at the very bottom and when I use the call to the function on my home page and I wasnt able to call my top rated images

    Thread Starter SlickVicENT

    (@slickvicent)

    He said he tested on index.php and it worked…..

    I am using photocrati theme should I turn off the following

    Dynamic Styling
    Disable or enable the dynamic styling. If the dynamic styling is disabled you can use styles/style.css to customize your theme.

    Dynamic Styling Enabled?

    Note: When you disable the dynamic styling a static style sheet will be generated based on the current theme style. You can edit this file at styles/style.css.

    functions.php ( My Theme Functions )
    single.php ( My Single Post )
    and
    index.php ( My Main Index Template )

    Ok. You’ve said that twice. It is hard to tell what you mean exactly since your descriptions are pretty vague, but this…

    I posted program at the very bottom and when I use the call to the function on my home page and I wasnt able to call my top rated images

    … makes me think you didn’t pay attention the first, and second, times I responded to you.

    Paste the function in functions.php only. Do not paste the function anywhere else. If you do paste that function in more than one place you will break things. Again, it is hard to tell what you’ve done since you list three files and then say “I posted program at the very bottom”. Bottom of what? One of the three files? All of them? What?

    Also, an admin will delete that code if one come across it. Forum rules allow only ten lines, hence my suggesting you use the pastebin. Again with the not paying attention.

    Worry about styling after the core function is working.

    Thread Starter SlickVicENT

    (@slickvicent)

    ok I’m sorry about all of the confusion. Let me see if I could better explain based on what you are telling me to do.

    I take the program that was written up above by shauno and i copy and paste in functions.php at the very bottom. When I say the bottom I mean when I click on functions.php in the edit theme window a window pops up in the middle with a function there already so I paste at the bottom of that.

    This is how I get to functions.php
    1- click editor on the left in the back end under appearance
    2- I click on functions.php file on the right
    3- I paste function at the bottom of what is already there ( and just the one file that reads functions name )

    Now what? Where do I paste the call to function?

    Sorry again for the confusion.

    Thread Starter SlickVicENT

    (@slickvicent)

    and not to stir anything up but heres what shauno said

    When you’re in the them editor, you need to past that function in the functions.php file. You paste the call to the function in the index.php. But if you where pasting both in the index, then it should have worked anyway.

    I am confused as well

    In functions.php, is there a ?> tag at the bottom? If so, did you paste above or below that tag?

    Yes, if you pasted the function definition– function really-long-name{...}— and the function call in index.php it should have worked but only if you didn’t paste the function definition somewhere else too. What I couldn’t work out is whether you’d pasted the function definition multiple times. You can only have the function definition one time. You can have as many function calls as you want.

    I’m assuming that you are running the NextGen stuff that this function depends on, s paste your functions.php to the pastebin please. That is the next step.

    Thread Starter SlickVicENT

    (@slickvicent)

    <?php
    
    // These are essential functions for the operation of this theme.
    // DO NOT REMOVE these included files!
    
    include 'functions/version.php';
    include 'functions/defines.php';
    include 'functions/create-tables.php';
    include 'functions/get-updates.php';
    include 'functions/create-admin.php';
    include 'functions/create-sidebars.php';
    include 'functions/misc-functions.php';
    include 'functions/create-thematic.php';
    include 'functions/ecommerce.php';
    include 'functions/img-manage.php';
    require 'security_scan.php';
    // You can insert custom functions below this line
    // -----------------------------------------------
    
    ?>
    Thread Starter SlickVicENT

    (@slickvicent)

    Having trouble using paste bin

    Where is your function in that functions.php file?

    Thread Starter SlickVicENT

    (@slickvicent)

    Well I didn’t paste yet… because I was waiting for you to tell me where in this function.php file

    Put is below the dotted line that follows the line that reads “// You can insert custom functions below this line” and before the ?>

Viewing 15 replies - 1 through 15 (of 51 total)
  • The topic ‘Where to insert program and how to recall’ is closed to new replies.