• Resolved Emilie

    (@emiliervgmailcom)


    So I used Post snippets to have some previous and back buttons among sibling pages. It worked while I was developing locally but now that I’m online, my buttons work but I get this warning above them :

    Warning: Missing argument 1 for siblings(), called in /var/www/html/wp-content/plugins/post-snippets/lib/PostSnippets/Shortcode.php(98) : eval()’d code on line 1 and defined in /var/www/html/wp-content/themes/daisho/functions.php on line 90

    Any idea on what could be wrong? Is there a way I can just disable the warning since it’s working anyways?

    http://ww.wp.xz.cn/extend/plugins/post-snippets/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Emilie

    (@emiliervgmailcom)

    Here is the code for the snippets :

    $links = siblings();
    
     $previous = '<span class="prev"><a href="%s"><i class="icon-chevron-left icon-2"></i></a></span>';
     echo sprintf($previous, $links['before']);
    
     $next = '<span class="next"><a href="%s"><i class="icon-chevron-right icon-2"></i></a></span>';
     echo sprintf($next, $links['after']);

    And the code in my functions.php :

    function siblings($link) {
        global $post;
        $siblings = get_pages('child_of='.$post->post_parent.'&parent='.$post->post_parent);
        foreach ($siblings as $key=>$sibling){
            if ($post->ID == $sibling->ID){
                $ID = $key;
            }
        }
        $closest = array('before'=>get_permalink($siblings[$ID-1]->ID),'after'=>get_permalink($siblings[$ID+1]->ID));
    
        if ($link == 'before' || $link == 'after') { echo $closest[$link]; } else { return $closest; }
    	}

    Thread Starter Emilie

    (@emiliervgmailcom)

    Hi,

    The problem is with your PHP code. The function siblings() requires an argument to be supplied to it ($link). And your snippet does probably not supply that argument when calling the function. And that is actually what the warning message says:

    Warning: Missing argument 1 for siblings()

    So change your function, to have a default value for that argument, so if no argument is supplied it takes that one, and you shall get rid of the warning.
    ie change
    function siblings($link) {
    to
    function siblings($link = '') {

    Cheers,
    Johan

    Thread Starter Emilie

    (@emiliervgmailcom)

    That solved it, thank you! 🙂 Great plugin btw, I just couldn’t find a plugin to insert PHP code that wouldn’t break because of the visual editor. Using shortcode did the thing.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Warning when online’ is closed to new replies.