Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter louis11

    (@louis11)

    Here’s the code for my shortcode, I more or less copied the example from the codex:

    <?php
    // List links
    function link_list($atts) {
        global $wpdb;
    
        // Defaults for the shortcode
        extract(shortcode_atts(
                array('num' => 100), $atts
        ));
    
        // Get the information from the database
        $table_name = $wpdb -> prefix . "links";
        $links    = $wpdb -> get_results("select * from $table_name where accepted = '1' limit {$num}");
    
        return build_form($links, 'List Plugin');
    }
    
    // Get the newest links from the database
    function link_newest($atts) {
        global $wpdb;
    
        // Defaults for the shortcode
        extract(shortcode_atts(
                array('num' => 25), $atts
        ));
    
        // Get the information from the database
        $table_name = $wpdb -> prefix . "links";
        $links    = $wpdb -> get_results("select * from $table_name where accepted = '1' order by id desc limit {$num}");
    
        return build_form($links, 'List Plugin - Newest links');
    }
    
    // Get the recently visited links from the database
    function link_visited($atts) {
        global $wpdb;
    
        // Defaults for the shortcode
        extract(shortcode_atts(
                array('num' => 25), $atts
        ));
    
        // Get the information from the database
        $table_name = $wpdb -> prefix . "links";
        $links    = $wpdb -> get_results("select * from $table_name where accepted = '1' order by time desc limit {$num}");
    
        return build_form($links, 'List Plugin - Recently Visted links');
    }
    
    // Add the previous functions to the Shortcode
    add_shortcode('newest_links', 'link_newest');
    add_shortcode('visited_links', 'link_visited');
    add_shortcode('list_links', 'link_list');
    ?>

    or on PasteBin: http://pastebin.com/d694ea769

    See anything wrong with that?

    Thread Starter louis11

    (@louis11)

    The shortcode I am using is based off the foobar shortcode example in the codex. In particular the shortcode takes the following form:

    [my_shortcode]

    Not sure what this type is called.

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