WordPress.org

Ready to get started?Download WordPress

Forums

Per Page Sidebars
Per Post Sidebars? (16 posts)

  1. patricktessels
    Member
    Posted 3 years ago #

    Could you maybe implement the functionality to also get custom sidebars per post? That would be really handy.

    http://wordpress.org/extend/plugins/per-page-sidebars/

  2. Brian Layman
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks for the input. I'll see what I can do.

  3. stuartwarner
    Member
    Posted 3 years ago #

    Hi Brian

    Really useful plugin thank you

    I agree with Patrick - would be useful to extend to posts as well as pages.

    Thank you

  4. ItsDan
    Member
    Posted 3 years ago #

    Also agree. I've tried adding the functionality myself, I enabled the meta box to appear on posts. It's saving that data, the new sidebar shows up in the widgets page. For some reason it's still showing the default sidebar, but I'm sure I'm missing something small. "Official" support for this would be nicer.

  5. ItsDan
    Member
    Posted 3 years ago #

    Posted too soon, it was working fine I just had the wrong sidebar to replace selected. So all I did was:

    in: pps_reg_custom_sidebar():
    if ( is_page() ) {
    to
    if ( is_page() || is_single() ) {

    in: pps_save_postdata():
    if (('page' == $_POST['post_type'] ) and current_user_can('edit_theme_options')) {
    to
    if (('page' == $_POST['post_type'] || 'post' == $_POST['post_type'] ) and current_user_can('edit_theme_options')) {

    and in: pps_add_custom_box():
    if ( current_user_can('edit_theme_options') ) {
    add_meta_box('pps_sectionid', __( 'Custom Sidebar', 'tcc_pps_domain' ), 'pps_inner_custom_box', 'page', 'advanced', 'high' );
    }

    to:

    if ( current_user_can('edit_theme_options') ) {
    add_meta_box('pps_sectionid', __( 'Custom Sidebar', 'tcc_pps_domain' ), 'pps_inner_custom_box', 'page', 'advanced', 'high' );
    add_meta_box('pps_sectionid', __( 'Custom Sidebar', 'tcc_pps_domain' ), 'pps_inner_custom_box', 'post', 'advanced', 'high' );
    }

    Not sure if that helps anyone. Neat plugin, I just finished a site which had a different plugin per page. Couldn't find this at first and was going to try and write one that integrated the widget editor on the post page itself, but this is SO much easier and less prone to fault.

  6. toddheitner
    Member
    Posted 3 years ago #

    I tried replacing the code per the previous post but it's causing an error for me:

    Parse error: syntax error, unexpected $end in /wp-content/plugins/per-page-sidebars/per-page-sidebars.php on line 231

  7. toddheitner
    Member
    Posted 3 years ago #

    Ok, I figured out what was generating the error. It was the last section of code replacement. It added an opening bracket { where there wasn't one in the original code.

    It should be like this:
    REPLACE THIS:

    if ( current_user_can('edit_theme_options') )
    		add_meta_box('pps_sectionid', __( 'Custom Sidebar', 'tcc_pps_domain' ), 'pps_inner_custom_box', 'page', 'advanced', 'high' );
    }

    WITH THIS:

    if ( current_user_can('edit_theme_options') )
    		add_meta_box('pps_sectionid', __( 'Custom Sidebar', 'tcc_pps_domain' ), 'pps_inner_custom_box', 'page', 'advanced', 'high' );
    		add_meta_box('pps_sectionid', __( 'Custom Sidebar', 'tcc_pps_domain' ), 'pps_inner_custom_box', 'post', 'advanced', 'high' );
    }
  8. ItsDan
    Member
    Posted 3 years ago #

    Todd, thanks for the info but I'm not sure you're correction has it right. There should definately be an opening bracket at the end of the line beginning with 'if'. There may be a missing closing bracket above that line though.

  9. toddheitner
    Member
    Posted 3 years ago #

    I would think so too, but that's where the error seems to be coming from. Here is the code from the original, unedited function:

    function pps_add_custom_box() {
    	// This security check is also verified upon save.
    	if ( current_user_can('edit_theme_options') )
    		add_meta_box('pps_sectionid', __( 'Custom Sidebar', 'tcc_pps_domain' ), 'pps_inner_custom_box', 'page', 'advanced', 'high' );
    }
  10. ItsDan
    Member
    Posted 3 years ago #

    The 'unexpected end' error can be misleading with the line number, it can only determine where it became certain the brackets weren't open/closed correctly. The error has to be above that line, as posted the 2nd add_meta_box function call would not be conditional. This would likely work it would just add the metabox to users who can't otherwise "edit_theme_options", but I would still bet on it missing from code above that line.

  11. toddheitner
    Member
    Posted 3 years ago #

    Well, it was definitely that section that caused the error. Line 231 is the last line of the file: ?>

    But you're right, there should be an opening bracket. There just wasn't one in the original file, so you need to add both an opening and closing bracket for the IF statement.

    So the function should look like this:

    function pps_add_custom_box() {
    	// This security check is also verified upon save.
    	if ( current_user_can('edit_theme_options') ){
    		add_meta_box('pps_sectionid', __( 'Custom Sidebar', 'tcc_pps_domain' ), 'pps_inner_custom_box', 'page', 'advanced', 'high' );
    		add_meta_box('pps_sectionid', __( 'Custom Sidebar', 'tcc_pps_domain' ), 'pps_inner_custom_box', 'post', 'advanced', 'high' );
    	}
    }
  12. toddheitner
    Member
    Posted 3 years ago #

    Now I'm running into a different issue. According to the plugin's installation instructions, it says there should be a new menu option for the plugin under Settings > Per Page Sidebar. However, I'm not seeing that.

    Just in case some of my changes messed something up, I reverted to the original files and there still is no menu option.

    When I go to a page I have a checkbox for using a custom sidebar, as well as radio buttons for which sidebar to replace, but there is nowhere to specify what appears in the custom sidebar, either on the screen where you edit the page or anywhere in the menus.

    I'm using the latest version of WordPress, version 3.1.1. Is it not compatible?

  13. ItsDan
    Member
    Posted 3 years ago #

    I don't have a menu option like that either, I think it's old documentation. Look in your widgets page.

  14. toddheitner
    Member
    Posted 3 years ago #

    I've looked in the widgets page but there's nothing new there. It seems to be just the standard stuff. What should I be seeing?

  15. ItsDan
    Member
    Posted 3 years ago #

    If you've enabled a custom sidebar on a post/page you'll see a new sidebar with the format pps-{slug} where slug is from the page you enabled custom sidebars for.

  16. toddheitner
    Member
    Posted 3 years ago #

    Ahhh... OK, I see. That's not how I was expecting it to work, but that's good. Thanks so much for your help!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic