• Resolved garybetz

    (@garybetz)


    I’ve been researching using a logical ‘AND’ in the shortcode to use two categories to control visibility of links, I ran across a thread here that offered two code additions to enable this. I tried each of these and was not able to get either of these to ‘AND’ two categories. I’m using Simple Links version 4.1.1 and WP version 4.9.4.

    I added each of the code additions to my subthemes’ template.php file and verified that they are being loaded (I added some output to the added code to verify they are being loaded). For neither of these solutions was I able to get anything to work.

    Suggested Solution #1
    First I tried the solution found here:
    https://www.ads-software.com/support/topic/and-filter-by-multiple-categories/#post-5293744.

    I added the both_categories=”1″ to the shortcode to get the following shortcode:
    [simple-links description = “true” category = “Press Page Links,Left Column” both_categories = “1”]

    When I add the both_categories=”1″ to the shortcode, I get no links output even though I have both the categories attached to the links. I would expect this code to interpret the shortcode as “display any link that has both ‘Press Page Links’ AND ‘Left Column’ specified for it”. I get no output when the both_categories is specified.

    Suggested Solution #2

    So, when this appeared to not work, I tried this solution here:
    https://www.ads-software.com/support/topic/and-filter-by-multiple-categories/#post-5293708

    I wasn’t able to get anything to work with Solution #2.

    So…any direction on this would be great.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mat Lipe

    (@mat-lipe)

    Hi garybetz,

    The code structure has changed a bit in the last 3.5 years which prevented the original snippet from working unless and orderby was set to something other than menu_order as noted here.

    I took another look at the code and found there was a clean way to work around this limitation and wrote a patch for the plugin. Version 4.4.2 was released just now which allows this filter to work without setting a special orderby.

    I also wanted to note that this feature will be built into the next minor release of the PRO version (1.2.0).

    Enjoy.

    Mat Lipe

    Thread Starter garybetz

    (@garybetz)

    Hi Mat,

    Sorry this took so long to test and respond. I was on another project.

    I’m still not sure this is working as I had expected. What I want to do is have 4 categories:
    1) Press Page Links
    2) Speaking Page Links
    3) Left Column
    4) Right Column

    I want to use these categories as follows:

    I want to create a shortcode that would list any links that have “Press Page Links” AND “Left Column” categories assigned to them. These would only appear on the Press Page in a section called “Left Column”. I would also create a second shortcode to select links for a “Right Column” on the Press Page. I also would do something similar for the Speaking page by using the category “Speaking Page Links” and have 2 columns of links using 2 additional shortcodes.

    Here’s the shortcode I have been trying to use for the Press Page which would put the links in a block to the left side of the page:

    [simple-links description="true" category="Press Page Links, Left Column"]

    What I’m seeing is that this is actually OR’ing the 2 categories and not AND’ing them. I also tried this shortcode which I found from an earlier posting which I thought might fix the issue:

    [simple-links description = "true" category="Press Page Links,Left Column" both_categories = "1"]

    I’m not sure if I missed something in your help text on the Settings page or there’s another way to do this. Your help would be gratefully appreciated. This plugin is pretty handy and will make link maintenance really easy for my authors. I just need the option to AND the categories.

    Thanks,
    gary

    • This reply was modified 6 years, 10 months ago by garybetz.
    Plugin Author Mat Lipe

    (@mat-lipe)

    Hello,

    I wanted to stop in to let everyone know that version 1.2.0 of PRO has officially been released with widget and shortcode options to Only include links assigned to all selected categories. Filters are no longer required.

    Look for the option labeled “Only include links assigned to all selected categories” of manually add both_categories=”true” to existing shortcodes.

    Enjoy!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘AND filter by multiple categories (revisited)’ is closed to new replies.