سؤال

I would like to place content in a sidebar of my blog articles when they are viewed in the archive, but not show this content when the blog articles are shown on the main page of my site.

Can this be done?

هل كانت مفيدة؟

المحلول

Another approach: edit your theme files. archive.php can simply not call in the sidebar, and that will do what you're asking.

Have a look at the Template Hierarchy for a view of what the individual files in a theme take care of.

نصائح أخرى

Wrap the content in a conditional:

if( is_archive() ){
  // Do stuff
}

More on conditionals here:

http://codex.wordpress.org/Conditional_Tags

I would recommend setting up multiple sidebars. Then you can call one sidebar for regular pages and a different sidebar for archive pages. This gives you complete control over which elements appear in the sidebar on each type of page.

Here's a good tutorial on creating multiple, widget-ized sidebars. You can manage each in the Appearance >> Widgets section of the admin dashboard.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى wordpress.stackexchange
scroll top