Support » Fixing WordPress » Newb with dynamic sidebar question

  • Hi, new WP developer here. I’m trying to add static content(actually, just an image and associated href) at the top of a right sidebar that contains blocks of dynamic content. The sidebar changes based on the section of the site the user is in.

    I’m having trouble finding where to add the code for the image. I do know PHP, but not so much WP. I found this code in sidebar.php:

    if (getTopID()==999) { dynamic_sidebar('About Us'); }
    else if (getTopID()==998) { dynamic_sidebar('Details'); }
    else if (getTopID()==997) { dynamic_sidebar('Projects'); }...

    So if I want to add the static image only above the ‘Details’ sidebar, and sorry if this is a dumb question, would I edit the ‘Details’ dynamic sidebar directly? If so, where would I locate the HTML if it exists for the dynamic sidebars?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Could you try adding the image IN the sidebar? That would save you from editing the theme code.

    1. Upload your image to your media library. Copy the url of the image location.
    2. Go to Appearance > Widgets
    3. Find the ‘Details’ sidebar
    4. Add a text widget to the ‘Details’ sidebar, above any other widgets in the sidebar.
    5. Add the code for the image location as html in your text widget.

    Now, this might be affected by some styling issues particular to your theme, but it sounds like you can probably work those out yourself..

    Thread Starter the_enn

    (@the_enn)

    Thanks a bunch – I’m with you… with one related question. 🙂

    I can drag the Text Widget from ‘Available Widgets’ over to the right under ‘Details’. Got it. And if I need CSS changes I could put it in the style sheet of the theme. Cool.

    One thing I noticed that there is what looks like a custom-built widget called ‘Default_Sidebar_Buttons’. This widget is simply two images on top of each other on the website. Thought maybe I could clone it. However, if I drag over the widget on the Widgets screen then expand it, there’s no HTML or image tags; it’s just blank.

    I did find related code in the functions.php file, but it looks pretty complex for displaying just two images (PHP functions, WP functions).

    Is it standard to build custom widgets just for an image href? Just wondering what purpose that would serve over adding HTML in a text widget.

    Couldn’t say for sure about any of that without seeing the theme, but it’s an interesting question.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Newb with dynamic sidebar question’ is closed to new replies.