1

Using Wordpress 3.8.1 with 'Twenty Fourteen' theme I'd like to arrange my post in such a way that it's main contents go to main (center) column while galleries, attached files and links pertaining to this post go to content sidebar to the right. How can I do that? Do I need some specific plugins?

Right now I can place in the content sidebar only site-specific widgets. I think that sidebar named 'content' and visually placed and styled like post should display post-specific widgets but I'm unable to force it to that.

  • 1
    The content sidebar are just a normal sidebar like all the others. The creator of twenty fourteen just gave it that name. It behaves and works just like the footer sidebar and the main sidebar. To do what you want you will have to code a widget specifically for that. – Pieter Goosen Feb 23 '14 at 11:29
1

You can install a plugin like widget visibility or Widget Logic which enables you to add conditional tags to specify which posts, pages etc your widgets display.

Otherwise, you would need to add the conditional tags to your themes native sidebar widget area's to control which posts, pages etc they display.

Example:

If you only wanted your widget to display on single posts, you would add the conditional tag:

is_single()

or

is_singular('post')

To exclude widgets from displaying on single posts, you would use the same conditional tag like this:

!is_single()

See this code example if you want to code your own custom sidebar widgets.

You can register the widget in your child themes functions file then hook it in directly in any template file or by using a custom functions in your child themes functions file.

Registers a new widget

add_action( 'widgets_init', 'wpsites_add_widget' );

function wpsites_add_widget() {

register_sidebar(array(
'name'=>'Custom Widget',
'id' => 'custom-widget',
));
}

Add to template file like single.php

<?php if ( is_active_sidebar( 'custom-widget' ) ) : ?>
<ul id="sidebar">
<?php dynamic_sidebar( 'custom-widget' ); ?>
</ul>
<?php endif; ?>

Source http://codex.wordpress.org/Function_Reference/dynamic_sidebar

1

While the logic can get complicated, you can control the display of widgets to a significant degree using the widget_display_callback filter.

For example, this will allow only the Core Text widget to be displayed in the sidebar with ID "sidebar-1" :

add_filter(
  'widget_display_callback',
  function ($instance, $widget, $sidebar){
    if (
      is_single()
      && 'sidebar-1' === $sidebar['id']
    ) {
      if ('WP_Widget_Text' !== get_class($widget)) {
        return false;
      }
    }
    return $instance;
  },
  10,3
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.