Forums

WP Publication Archive
Category filter is not working and shows all files (6 posts)

  1. sanjeevsajjan
    Member
    Posted 4 months ago #

    I am giving the following shortcode for category having slug "cat1":
    [wp-publication-archive categories="cat1"]

    However, all the publications under cat1 and cat2 are showing. Same thing is happening for this also :
    [wp-publication-archive categories="cat2"]

    At both the pages, all publications are showing up and filter is not working.

    Please let me know if I am doing something wrong or problem lies somewhere else.

    Thanks.

    http://wordpress.org/extend/plugins/wp-publication-archive/

  2. Eric Mann
    Member
    Posted 4 months ago #

    The shortcode you're using looks fine, but without actually seeing your site and the publications I can't provide any further help.

  3. pheriche
    Member
    Posted 3 months ago #

    I am having exactly the same problem .
    I have created some categories and uploaded some PDF files and assigned them to categories.
    Using the shortcode like
    [wp-publication-archive categories="newreleases"] however gives a list of all files in all categories.
    The author filter works as expected but I cannot get the categories filter to work .
    I cannot provide a URL as I am testing this on localhost

  4. pheriche
    Member
    Posted 3 months ago #

    I have solved this... nearly.
    If I make the category name exactly the same as the slug then the category filter works.
    What alerted me to this was when I echo the mysql queries to the page by setting
    define( 'SAVEQUERIES', true );

    I looked through the queries for the name of the slug I was using in the shortcode and found this query .
    SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'category' AND t.name = 'new-releases' LIMIT 1
    This was returning no rows because the query is searching the name field of wp-terms and not the slug field.

    I have not yet tracked down which part of the plug-in code generates this query but I guess a workaround is to use the category name in the shortcode filter rather than the slug.

  5. Eric Mann
    Member
    Posted 3 months ago #

    The processing for this is in /lb/class.wp-publication-archive.php around line 233. The plugin takes the category names passed in and queries the database to get their IDs. This list of IDs is then passed in a larger query to retrieve publications mapped to those categories.

    It's using the core get_cat_ID() function, which takes a category name rather than a category slug. If there was any confusion in my documentation, it's entirely my fault and will be fixed in the future.

  6. pheriche
    Member
    Posted 3 months ago #

    Thanks for the info Eric. And the useful plugin.

Reply

You must log in to post.

About this Plugin

About this Topic