Forum Replies Created

Viewing 15 replies - 16 through 30 (of 77 total)
  • Forum: Fixing WordPress
    In reply to: Author Edit Link

    There’s a reason your questions don’t get answered. Lacking in clarity & respect.

    This should work, back up before trying though.

    Add this to functions.php (located in p2’s theme directory).

    /* the following tweak filters the front page to only contain a single category of choice */
    add_action('pre_get_posts', 'front_page_cat_filter' );
    
    function front_page_cat_filter()
    {
      global $wp_query;
      $cat = get_cat_id('post');
      if( is_home() || is_front_page () ) {
         $wp_query->query_vars['cat'] = $cat;
      }
    }
    /* end of tweak */

    then in ajax.php, on line 245 in the most current version of p2 inside the ‘get_latest_posts()’ function, find the line:
    query_posts( 'showposts=' . $num_posts . '&post_status=publish' );
    and replace this with:

    /* tweaking the updated posts to only include a certain category */
    if (is_home () || is_front_page () ) {
    query_posts( 'showposts='. $num_posts . '&post_status=publish&category_name=post');
    }
    else
    {
    query_posts( 'showposts=' . $num_posts . '&post_status=publish' );
    }
    /* end of tweak */

    Depending on the category you want to show, you have to replace the word post with your desired category (so…category_name=<type your category here>) and get_cat_id(‘<type your category here>’)

    I haven’t tested this extensively but it should establish what you want to do.

    * made a few small corrections since posting this

    For other themes this is pretty straight forward, the above solution would work, but because P2 injects new posts via ajax (it continually checks for updates a user might have posted while you’re on the page), you’d still get live posts that happen when another users posts outside of the desired category appearing on the frontpage regardless of the above tweak. You’d need another few tweaks to fully get the effect. I’m not sure you want to edit multiple files but I could share how, if you like.

    P2 child themes work great when all you have is css/layout tweaks and some basic addons that don’t change the basic p2 functions. Other types of edits such as these can get messy and it kind of defeats the purpose of easy updates because it introduces a hassle to make everything work. P2’s a theme that gets continually updated so if you’re making significant changes you can easily either break your theme or lose out on updated code. If you go with flamenco’s solution for example, if a future p2 update includes changes to the original options-page.php file, you’re missing out on it (and it could break your theme if other updated code relies on the changes).

    I hope the great folks behind P2 think about making substantial customization more user friendly. Some ideas are adding hooks, converting part of P2’s functionality into a plugin or putting together more theme settings options that cover popular features such as category selection and giving users more control over what boxes/post types appear.

    As it stands sometimes it’s more convenient to forgo theme updates when you have made significant modifications, which is only fine as long as there are no security holes needing to be plugged/or bug fixes needing to be corrected.

    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.

    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'; }

    would be fun to implement but I don’t have spare time to allocate at the moment. Are you serious about the feature? Would do it for pay…or you could try rentacoder or scriptlance or something similar. Maybe someone else has the time to implement?

    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.

    Here’s where I would start:
    An easy way to play sounds is with this script: http://www.happyworm.com/jquery/jplayer/

    you’ll obviously want a sound file like ding.mp3:)

    Then fire the play function when a post/comment gets made by editing p2.js in your p2 theme.

    You’ll need to know how to add the scripts and a little javascript to get it working.

    This can be done, it’s not too hard…Nice idea, reminds me of the good ol’days when incoming emails prompted sound notifications (although outlook still has it).

    fyi, I just checked p2 v1.1.7 and above code still works for me.

    here is probably the most informative thread regarding categories + p2 so far, had you checked it?
    http://wordpress.org/support/topic/dropdown-category-selection-for-publishing-posts-in-p2-theme-v113

    @nathan I’ve uploaded a copy with drop categories for 1.1.5, it seems to be working fine on my end. The code I had stated earlier still works, it’s just the line numbers have changed a bit (the code that is being replaced has not). I put the download on sendspace.

    @dini
    possible yes, do you want a user to click on a button after selecting a category or are you wanting the change to happen dynamically? Not sure about the latter but think it can be done with ajax. Front-end-editor plugin by Scribu is a great starting point.

    stoupon, do you still want a look at the code or have you settled on a different solution?

    I’m doing some work on my theme this month and picking up development again when I get back from a 2 week trip. Cool new part: producteev integration.

    Forum: Plugins
    In reply to: User Photo Plugin

    so what you want is for a manually uploaded photo from a user to get priority over a gravatar image?

    have you tried surfalot’s solution:

    <?php
    	$the_photo = '';
    	if (function_exists('userphoto__get_userphoto') && defined('USERPHOTO_THUMBNAIL_SIZE') && !empty($comment->user_id))
    		$the_photo = userphoto__get_userphoto($comment->user_id, USERPHOTO_THUMBNAIL_SIZE, /* before */ '', /* after */ '', array('class' => 'avatar'), /* def src */ '');
    	if (!empty($the_photo)) echo $the_photo;
    	else echo get_avatar( $comment, 32 );
    ?>

    you’ll need to edit functions.php at line 134 in p2 1.1.5.
    this is what you need to replace with above:
    <?php echo get_avatar( $comment, 32 ); ?>

Viewing 15 replies - 16 through 30 (of 77 total)