WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Change Text Widget Content Through Custom Fields (11 posts)

  1. poojim
    Member
    Posted 2 years ago #

    Hello everyone!

    New here in forums. I was actually looking for a way to change a "text widget" content through custom fields in the post editor. Or are there any plugins that can help me.

    I want to have a changing content for sidebar per post wherein I can change the sidebar content through post editor. The best thing I thought that can help me is through a "changing dynamic text widget" that can be edited for every post. Moreover, text widget can read html codes and other codes.

    I also thought of adding more dynamic sidebars but that won't be practical if I like different contents per post. That means I would have to create many dynamic sidebars.

    If you have any ideas please help me thank you!

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    Try it with this widget: http://wordpress.org/extend/plugins/php-code-widget/

    What is it you want to do exactly? Show some content you put in a Custom Field?

  3. chadrew
    Member
    Posted 2 years ago #

    Something like this I guess (where NAME is the name of the custom field):

    <?php
    if (is_single() && get_post_meta($post->ID, 'NAME', true)) {
    echo get_post_meta($post->ID, 'NAME', true);
    }
    ?>
  4. poojim
    Member
    Posted 2 years ago #

    okay. Thanks for the replies,,,

    To be specific I want a custom sidebar content that changes per post. I knew we can create different sidebars per post but that won't be practical.

    I'll try your suggested plug in keesiemeijer because it can call php plus the code given by chadrew.

    "What is it you want to do exactly? Show some content you put in a Custom Field?" - Yes! and show them in the sidebar....

  5. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Sidebars are not 'in the loop'...you can create a table in your post or page with content that shows on the right or left, and use a theme that turns off the main sidebars on post or pages...

  6. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    You can also use templates

  7. poojim
    Member
    Posted 2 years ago #

    chadrew, it isn't working... (whether the code or the plugin

    swanson, I find it boring to read all those but I got the thoughts that it's probably not on the loop since there is no <?php get_sidebar(); ?> on my single.php

  8. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    My intention was to help...Just call me turtle.

  9. poojim
    Member
    Posted 2 years ago #

    okay thanks turtle....

    So how do I do this? Am not very good with php:

    "Sidebars are not 'in the loop'...you can create a table in your post or page with content that shows on the right or left, and use a theme that turns off the main sidebars on post or pages..."

  10. chadrew
    Member
    Posted 2 years ago #

    Just put the code I gave you in your sidebar.php file (somewhere under all the widgets, I guess). And don't forget to replace NAME with the actual name of the custom field. I just tried it and it worked for me.

  11. poojim
    Member
    Posted 2 years ago #

    what the... yeas it worked! At first I tried calling it in a widget. I didn't tried it on sidebar.php cause I didn't got the logic... Now I'm ashamed. lol. Thanks chadrew!!!....

Topic Closed

This topic has been closed to new replies.

About this Topic