WordPress.org

Support

Support » Plugins and Hacks » Per Page Sidebars » [Plugin: Per Page Sidebars] Per Post Sidebars?

[Plugin: Per Page Sidebars] Per Post Sidebars?

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Brian Layman

    @brianlayman

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

    Hi Brian

    Really useful plugin thank you

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

    Thank you

    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.

    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.

    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

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

    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.

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

    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.

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

    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?

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

    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?

    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.

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

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Plugin: Per Page Sidebars] Per Post Sidebars?’ is closed to new replies.
Skip to toolbar