maugustyniak

My work and projects


misiek-page-category

http://wordpress.org/extend/plugins/misiek-page-category/

19 Responses to “misiek-page-category”

  1. undrskor says:

    Hello,

    Great plugin! I’ve been looking everywhere for something like this. I was wondering how can I query a category to display the pages within that category?

    Thanks in advance.

  2. misiek says:

    glad you like it.

    That is good question, and I came back to the code discovered few bugs, I released 1.2 version now.
    I added also for you order by post_title for displaying pages in category.
    Sorry, but it would take more time for adding this option in administration, so if you will go to category.php file and change $order_by variable for what ever you in mpc_get_page_category($id, $order_by = “post_title”) function , this will do it. line 181
    $order_by should be existing column in wp_posts table.

    Godd luck , let me know if you need more info
    Michal

  3. undrskor says:

    Thanks for the update.

    Actually I wanted to display a specific category’s pages in a post or page, not in the widget. Just like querying a specific category for posts using query_posts(‘category_name=blah’); Is there a way I can do something like this?

    Thank you for your help.

  4. misiek says:

    there is no way at this moment, but if you’ll give me few days I will make this happen for you, I am just super busy this week

  5. undrskor says:

    Yes I don’t need this at the moment, but thank you for helping me with this.

  6. fairyfly says:

    how if i wanna put the category on a page not on sidebar widget? can u give me the code pls? i’ll be waiting for ur reply..thank u..

  7. Is it possible to not show some pages?
    Like in the standard Pages menubar?
    I’m looking forward to hear from you.

    Best regards,
    David

  8. Hi, nice plugin!

    Will be very useful for an upcoming site build. I would also like to be able to use a function in a template to call all pages in a category, and show the total number of pages within that category, eg:

    Categories:

    - Category A (4)
    - Category B (6)
    - Category C (2)

    Each category in the list would link to a “Category” page (which uses get_pages to list pages in the category)

    Do you think this will be possible? If I get it working, I will send you the code to add to the plugin.

    Jack

  9. misiek says:

    yes, this all is of course possible and i will implement when i get a chance. I am not lazy at all just super busy now. I will try do it as soon as i can maybe by the end of the weekend ?

  10. fairyfly says:

    misiek: im glad that u will answer my wish, i can’t wait to show ur plugin in my post/page (not widget sidebar) thx..lookin forward to it :)

  11. Brandon says:

    Hi Everybody,

    I see a lot of people asking for a way to get pages by category outside of the widget. I actually needed this so I could use this plugin to categorize pages into different navigation areas on the page. As in I need some pages to be in the head nav, some in the footer nav, some in both. And I needed to get them by category name rather than id.

    So I wrote a quick function that you can add to category.php that you can call from your template files. It gets all pages in a category by category name and returns them all as list items. It works just fine. However, I don’t want to post it without Misiek’s permission, since it’s his plugin.

    So Misiek, with your permission I’ll go ahead and post that function. Let me know.

    Thanks,
    Brandon

  12. misiek says:

    Brandon

    Please go ahead and post it.

    Sorry guys for not dealing with that how I promised weeks ago. Just so so busy . If you have any ideas to get some stuff better please feel free to post all the code here or the patches. Please just make good enough docs to not confused people.

    Thanks
    Best
    misiek

  13. Brandon says:

    Alright guys. Here’s what I got. I’m hoping I can just post some php code here without it getting parsed. I don’t see a tag for posting code in this submit box.

    @misiek

    No worries man. We all appreciate the free plugin. That’s the beauty of open source software. We all have needs and we all try to help each other fill them. But feel free to give my website a shoutout. We’re a small web development company and could use the traffic.

    Without further a due, here’s the function. Put this at the end of category.php. Before the closing ?> of course. You can then call the function from your template files as

    Of course you can choose your sort method same as before. I use the my page order plugin to order my pages, so menu_order works best for me.

    Here’s the actual function:

    // This was added by Brandon Tate. I needed to list pages by category and call it by category name.
    // Feel free to let me know if you need anything programming related. You can find me at
    // brandon@metaforgestudios.com or at my website http://www.metaforgestudios.com
    // Thanks to misiek for a great plugin
    function mpc_list_page_by_category_name($name, $order_by = "post_title") {
    global $wpdb;
    $data = "";
    $cat_id = $wpdb->get_row("select id from " . MPC_CATEGORIES . " WHERE name = '$name';");
    $cat_id = $cat_id->id;
    $pages = $wpdb->get_results("select * from " . MPC_PAGES_CATEGORIES . " inner join " . POSTS . " on " . POSTS . ".ID = " . MPC_PAGES_CATEGORIES . ".post_id where category_id = {$cat_id} order by {$order_by}");
    //print_r($pages);
    $first = true;
    foreach($pages as $page){
    $post = &get_post($page->post_id);
    $link = get_permalink($page->post_id);
    $data .= "" . $post->post_title . "";
    $first = false;
    }//end foreach
    return $data;
    }

    FROM:misiek
    Brandon you’re right, no way to format this better!

  14. Brandon says:

    Just a side note. I’ve seen issues in the past with forums, or email, or any number of medium, encoding quotes/double quotes in their own style. So you’ll probably need to watch out for that when copying and pasting.

    Just a friendly warning.

    I’ve missed it in the past and it’s a pain in the ass to debug sometimes.

  15. Brandon says:

    I noticed this isn’t working, as far as posting goes. @Misiek: Please send me an email at brandon@metaforgestudios.com. I’ll send you the code and you can post it. I don’t think I can do it through the quick submit. Thanks.

  16. I wanted to show lists of pages in a category, but not in the widget, so I grabbed one of the functions out of the latest version of the plugin, and got this:

    <?php

    $p_categories = mpc_get_page_category(3);
    print "”;

    foreach((array)$p_categories as $p_category) {
    $post = &get_post($p_category->post_id);
    $link = get_permalink($p_category->post_id);
    print “” . $post->post_title . ““;
    $post->post_content;
    print “”;
    }
    print “”;

    ?>

    Now, the next question is – I’m hard-coding the category number. I’m looking for a way, based on the current page, to find that category number automatically and insert it as a variable…

  17. Regarding extra quotes – you can see in my code above that it added extra quotes around the post_title section – other than it looks clean enough to use.

  18. Sorry, spoke too soon – my eyes are getting weak – there are double quotes everywhere… sorry

  19. Just realized that the template coding I just put up will pull all pages, even scheduled ones. I went into the plug-in file and create a new function:

    function mpc_get_published_page_category($id, $order_by = “post_title”) {
    global $wpdb;
    return $wpdb->get_results(“select * from ” . MPC_PAGES_CATEGORIES . ” inner join ” . POSTS . ” on ” . POSTS . “.ID = ” . MPC_PAGES_CATEGORIES . “.post_id where category_id = {$id} and post_status = ‘publish’ order by {$order_by}”);
    }

    [Note that the comments area is putting in extra quotations into this coding]

    Substituting this function in the template coding I submitted earlier on October 8 will keep scheduled pages out of the results [I had a client who is scheduling pages the way people usually do for posts].

Leave a Reply