• Resolved online

    (@online)


    I use P2 on many blogs (in a network) and have different default categories in each blog.

    Would it be possible to allow the default category to pass the “accepted post cats” test?

    Do I need to do this myself (and if so, how 😉 or could this maybe be changed in the P2 theme “out of the box”?

    Of course I prefer the latter! ;D

    TIA 🙂

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter online

    (@online)

    did I post this in the right forum?

    o_O

    One way of doing it is adjusting the following line in ajax.php

    $post_cat = ( in_array( $_POST['post_cat'], $accepted_post_cats ) )

    to

    $post_cat = $_POST['post_cat'];

    or you can add your desired category to the list of accepted post categories, the problem is that it is hardcoded into the theme and thus the manual tweaks in the code. Maybe in a future version they can add some more options and flexibility to incorporate more usage scenarios.

    Thread Starter online

    (@online)

    oh, that’s *easy* — even *I* can do that! 😀

    thanks Nobble!

    (and yes, this would be a nice “tweak” — maybe it could be implemented to *add* categories instead of replace them?)

    Thread Starter online

    (@online)

    it isn’t working :/

    is the semicolon supposed to be included?

    and what about the rest of the line — the full line reads:

    $post_cat = ( in_array( $_POST[‘post_cat’], $accepted_post_cats ) ) ? $_POST[‘post_cat’] : ‘post’;

    sorry I didn’t paste what needs replacing in its entirety,
    as of the latest version the lines 195+196, comment them out:

    $accepted_post_cats = apply_filters( 'p2_accepted_post_cats', array( 'post', 'quote', 'status', 'link' ) );
    		$post_cat = ( in_array( $_POST['post_cat'], $accepted_post_cats ) ) ? $_POST['post_cat'] : 'post';

    and replace with
    $post_cat = $_POST['post_cat'];

    it’s not the only change you’ll need to make as you’ll need to pass on what the default category is as well either by changing the submit form and associated code or doing a bit of a hack, for example:
    if ($post_cat == 'blog ') { $post_cat = 'yourdefaultcat'; }

    Thread Starter online

    (@online)

    oh, but the point is that the default category varies from one blog to the next.

    that’s what I mean: I want any blog using this theme to be able to specify it’s own default blog category (under “settings” – “Writing”) — just like in other templates.

    TBH IDK why the different posting formats in P2 require these categories — I mean its nice if it works, but I do also want to be able to specify a default category that is unique to each blog.

    What are you doing with the other post formats to go along side the default post type that you want to allocate to the default category?

    this code placed after $post_cat = $_POST['post_cat']; would set the ordinary blog post format p2 uses to adopt your default category instead:

    if ($post_cat == 'blog') { $post_cat = get_cat_name( get_option('default_category')); }

    haven’t tested this + you’d still have the other post formats p2 uses associated with their own formats like the quote, status and link categories.

    Thread Starter online

    (@online)

    Cool — that works! 😀

    IMO there doesn’t need to be any conditional statement — at least not if the default category could be *ADDED* rather than *REPLACING* any of the other categories. That way — if the default category is set to one of the 4 hard-coded categories, then it wouldn’t really change (well, it wouldn’t change insofar as it matches the default format [i.e. “status”]), but otherwise it would *add* the default category to the hard-coded category (such that each new post would have 2 categories — the hard-coded category *plus* the default category which the admin configures under “Settings” – “Writing”)

    (BTW: in your conditional statement I changed ‘blog’ to ‘post’)

    I use many blogs in a network, and I share information across blogs based on the categories of posts, so this change is really crucial for me to be able to implement P2 the way I use my blogging network — WOOHOO! 😀

    Thread Starter online

    (@online)

    just a little “extra” idea — maybe it might be good for P2 options to have checkboxes for the different posting formats, such that people could pick which posting formats to include in their blog (maybe you could even order them from left to right, but that seems very much like overkill ;)… and it might be cool for the default posting category — if it matches a hard-coded category — to be the default posting format

    I realize I have probably suggested something that amounts to something like a year of work, but I’m just very imaginative like that! 😉

    Hi Nobble

    I have the same problem that online had 3 months ago… and i read this thread and tried to make the changes to ajax.php…. however it doesnt seem to be working… I was wondering if the changes you suggested still work or has the p2 code been updated since then?

    I added

    if ($post_cat == 'post') { $post_cat = get_cat_name( get_option('default_category')); }

    Under

    $post_cat = ( in_array( $_POST['post_cat'], $accepted_post_cats ) ) ? $_POST['post_cat'] : 'status';
    
    		if ( !category_exists( $post_cat ) )
    			wp_insert_category( array( 'cat_name' => $post_cat ) );
    
    		$post_cat = get_category_by_slug( $post_cat );

    But the post just goes to the ‘post’ category???

    Any suggestions?
    Please… 🙂

    I will have a look at the latest P2. I’m assuming you’ve set your default post category in WP settings (write panel) to something other than ‘post’?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Can default category be allowed to pass through accepted_post_cats in P2 theme?’ is closed to new replies.