• Hello Shaun:

    First, congratulations for your excellent plugin!. I’m the webmaster of a dog shelter association (HUELLAS puertollano); we have more than 200 abandoned dogs, our web is the only way we have for trying to find a new home for them. I selected the blog format, as it is simple to create a post per dog, and feature the most urgent, etc etc. Now, I want to use your plugin for easily (automatically in fact) create a census of the dog population. By creating custom fields in the posts, I can include the phone or e-mails for those that are in temporary taking in.

    So far, I can only create a table of all of the posts, I would like to display just the posts of one category, is it possible? I found an option to use cat=”xxx” for custom taxonomies, I expected this option to work also with existing categories, but it seems I’m doing something wrong. You have my attept to use it in this URL

    I would like to contribute to compensate your excellent work, but our association is really in red numbers. I’m sorry – consider this as your contribution to our dogs πŸ˜‰

    Thank you very much in advance

    http://wordpress.org/extend/plugins/sorttable-post/

Viewing 15 replies - 1 through 15 (of 15 total)
  • Mcanay, I’m not the author of this plug-in, but I was looking to do what you are (make it show only 1 category of posts) and I have a really bad hack to make it work. Note that this will make the plugin only work with 1 category, and you can’t create new tables using other categories. I don’t know PHP and I just barely threw this together.

    First, you need to open the file sorttablepost.php (which is found in the plugin’s folder) in a text editor. Find this line:

    $sorttable = new WP_Query( array( 'posts_per_page' => -1, 'post_type' => $opt_type, 'orderby' => 'date', 'order' => 'DESC' ) );

    And change it to:

    $sorttable = new WP_Query( 'cat=579', array( 'posts_per_page' => -1, 'post_type' => $opt_type, 'orderby' => 'date', 'order' => 'DESC' ) );

    Now you need to change the number 579 to the category ID of the category of posts you want to show. Finding the Category ID number is a little harder than you think. In the WordPress Dashboard on your site, go into Posts–>Categories, find the Category you want to use, and select edit. Now look in your browser’s URL address bar, skim through the address until you see:

    category&tag_ID=579

    Only 579 will be a different number. That’s the number you’ll use to replace the 579 in “cat=579” in my example code.

    Now, save sorttablepost.php and upload it into the plugin’s folder already uploaded to yoursite, replacing the original version.

    Everything about the plugin should work as before, except the posts listed will only be within that 1 category. Again, this is a bad hack, but it works. Hopefully the author will update the plug-in with a way to limit the posts listed to specific categories, tags, custom fields, etc.

    Thread Starter mcanay

    (@mcanay)

    Hello goldenglishgrammar:

    Thank you very much for your help, I’m not very familiar at all with php but I’m doing my best, I even translated the theme to spanish before the author did it…you suggestion woks fine for a single category, unfortunately I need to handle the native categories that I created for the animals: male/female/big/small/already adopted/etc because I will like to have trackof all of them. I have other posts like ‘news’, ‘donations’, ‘useful info’ etc which are not animals, but are posts in the end, so…as it is for my use, I will swallos the info to appear in the table and that’s it. A little bit of imperfection helps to better understand our world.

    Thanks again!
    Miguel

    Isn’t there a way to make this plugin show only one category – but do it in a way so as to preserve the ability to show a different category on a different post or page?
    This method essentially brute forces one category only total right?

    Thanks in advance for some ideas.

    Here’s what you can do.
    Comment out or delete the current query on line 113. It looks like
    $sorttable = new WP_Query( array( ...

    In its place put this code that is copied from the get_posts function.

    $defaults = array(
    		'numberposts' => -1, 'offset' => 0,
    		'category' => 0, 'orderby' => 'post_date',
    		'order' => 'DESC', 'include' => array(),
    		'exclude' => array(), 'meta_key' => '',
    		'meta_value' =>'', 'post_type' => $opt_type,
    		'suppress_filters' => true
    	);
    
    	$r = wp_parse_args( $args, $defaults );
    	if ( empty( $r['post_status'] ) )
    		$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';
    	$sorttable = new WP_Query( $r );

    Now you can use the shortcode with any of the parameters shown on the WP_Query page except for some of the complicated taxonomy queries which require arrays. Those would need a bit more code.

    Hi Joy, everyone,

    I am trying to do something similar with this plugin. I have a Custom Post Type with its own Taxonomies. I want to list a table of a specific Taxonomy from that Custom Post Type on a Page.

    Would I need to use more code than code Joy has described?

    Thanks!

    I just tried it using the first syntax described on the WP_Query page under taxonomies and it worked. The example is to display posts tagged with ‘bob’, under ‘people’ custom taxonomy, so I put it in the shortcode as
    [sorttablepost type="mycustomtype" people="bob"]

    Great, thanks so much Joy. It is working perfectly. I appreciate all of your help!

    Hello, Thank you Joy for providing that code to filter by category.

    I could not get it to work. I deleted the old code as you indicated from ‘sorttablepost.php’ (which for me started at line 223 under comment “// Begin the loop to generate the table body”). And, then posted your code above.

    It broke the page, so I removed it. I may have done something wrong, but I’m not sure.

    The page I want the sortable, filtered by category table on is here: http://winetrailseast.com/on-the-trail/wine-trails/

    It will only be of use to me if I can filter out all categories except wine trails.

    Any help on this would very much be appreciated.
    best regards, Nancy

    Nancy,
    I don’t know what you did to your code, but mine works. I am talking about line 113 of sorttablepost.php. That file has only 223 lines to start with. The comment you referenced is on line 112.
    Delete or comment (put // in front) only line 113 as noted above and insert the new code in its place.

    You might want to start with a fresh copy of the file to make sure you have the right one.

    Thread Starter mcanay

    (@mcanay)

    Hello all:

    Joy: I tried and it does something but does not pick all of the entries of the category…it’s really strange. I also tried by ‘category_name= ‘instead of ‘cat= ‘ but I get the same results. In fact, those posts selected by the command have nothing to do one to each other.

    I did not answer before because I had to solve some bigger problems in our shelter, as the blog works so far (even without table…) thanks to it, we were able to find home for 110 dogs this year. And all through the blog!!! They see the dogs for adoption (176 right now, we still need to produce posts for other 80 or so), they fill the adoption form, and submit the adoption query.

    Thanks so much for your help, I’ll keep trying…

    Thread Starter mcanay

    (@mcanay)

    And Merry Christmas to all of you!!!

    Thank you Joy, worked like a champ!

    Hello All!
    I wanted to do the same thing (list posts from a specific category)
    But since im not at all a programmer i simply used the “Custom Post Type Maker” and changed my shortcode to:
    [sorttablepost type=”my-custom-post-type”]

    It doesnΒ΄t really help someone who has a blog full of content but if you are in the making of a site this might be useful.

    Cheers!

    Hello guys!
    Here is a solution how to use SortTable Post to list post of a selected category on a separate page.

    1) Download the sorttablepost.php and modify it as follows;

    2)Find line: // Get options from shortcode and generate SortTable

    3) Go 10 lines below to line: $opt_notags = $args[‘notag’] . $args[‘notags’]; // Boolean, default ‘false’

    4) Insert two lines after the above line:
    $opt_catids = $args[‘catid’] . $args[‘catids’]; // Boolean, default ‘false’
    define(“category”, $opt_catids);

    5) Find line:
    $sorttable = new WP_Query( array( ‘posts_per_page’ => -1, ‘post_type’ => $opt_type, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ) );

    6) Modify (or replace) line found as (with):
    $sorttable = new WP_Query( array( ‘posts_per_page’ => -1, ‘cat’ => category, ‘post_type’ => $opt_type, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ) );

    7) Find IDs for all your categories and create respective post pages (one per category); create pages based menu;

    8) Edit every created page, placing shortcode: catids=X into the standart shortcode line, where “X” is the respective category ID number. Example:
    [sorttablepost nothumb=”true” notags=”true” catids=9]
    The above shortcode line will result in table without thumbs and tags and it will have post with the category ID=9

    Good luck!

    P.S.
    Obviously you would have to upload modified file back to your phugin’s directory. Always backup the original πŸ˜‰

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Plugin: SortTable Post] Displaying posts of just one category’ is closed to new replies.