WordPress.org

Ready to get started?Download WordPress

Forums

Simple Links
[resolved] customizing the widget (8 posts)

  1. meeble
    Member
    Posted 1 year ago #

    Hello,

    I know that this isn't a feature of the plugin, but...

    I want to be able to customize the simple links widget code so that only posts(links) that have a certain value stored in a custom field for that post are displayed. (I am using Advanced Custom Fields - so I'm using standard WP custom fields stored in the postmeta table.)

    i.e. I have a custom field named "metro", and let's say one of the Simple Links posts has a value of "phoenix" for that field. What is the best way to specify to only display posts(links) that have a "metro" value of "phoenix", etc.

    Thanks in advance!

    http://wordpress.org/extend/plugins/simple-links/

  2. meeble
    Member
    Posted 1 year ago #

    Ok, I figured out how to modify the widget query using code like this:

    $query_args['meta_query'] = array(array( 'key' => 'state','value' => array('','arizona'),'key' => 'metro','value' => array('all','phoenix') ));

    but...

    I haven't had much luck in modifying the widget query based on link categories. Any help would be appreciated!

  3. meeble
    Member
    Posted 1 year ago #

    Sorry to be such a bother,

    I would also like to take all the links of a certain link category and output them on a page, but I would like to format the output into a 3 column table. Is there an easy way to use the built-in filters to accomplish this?

    Thanks

  4. Mat Lipe
    Member
    Plugin Author

    Posted 1 year ago #

    Hello,
    You may select the category on the widget options to output a certain category's links.

    To change the output into a table you may use the simple_links_widget_output filter like so.

    add_filter('simple_links_widget_output','change_widget_output', 0 , 4);
    function change_widget_output( $output, $links_object, $instance, $args ){
          return $output;
    }

    The second argument $links_object will be all the data associated with the links in that category. You may output the links however you would like using the data from that object.

    Otherwise to achieve a 3 column layout without a table you would style the default list items generated by the widget to layout that way like so

    .simple-links-list li {
    width: 30%;
    float: left;
    margin: 0;
    padding: 0;
    list-style-type: none;
    }

    Hope this helps.

    Cheers

  5. meeble
    Member
    Posted 1 year ago #

    Hi Matt,

    Thanks for the response. So, if I already have two instances of the SL widget on my site, and I add a 3rd for this purpose, how do I specify:

    a. that the filter uses the output of the 3rd widget?
    b. to not display the 3rd widget in the sidebar?

    Thanks,
    Devin

  6. Mat Lipe
    Member
    Plugin Author

    Posted 1 year ago #

    The filter supports specifying the the id of the widget for instance

    simple_links_shortcode_output_simple-links-3

    would target the widget with the id simple-links-3.

    You may have to look at the page's output to see what the id of the specific widget you are targeting. As long as your theme is using a proper before_widget when creating your widget area, all SL widgets will have an id.

    The easiest way to remove it from the sidebar is to target it with CSS like so: Assuming your sidebar has an id of 'sidebar'

    #sidebar #simple-links-3{
       display:none;
    }
  7. meeble
    Member
    Posted 1 year ago #

    For now, I am just using a shortcode on a page to output the links of a certain category, which does the job. But for some reason, I can't get your css to work on the output.

    .simple-links-list li {
    width: 30%;
    float: left;
    margin: 0;
    padding: 0;
    list-style-type: none;
    }
  8. meeble
    Member
    Posted 1 year ago #

    never mind my last post, bad css code was breaking my stylesheet.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic