Using the post title in sidebar template (2 posts)

  1. metrorock
    Posted 2 years ago #

    I am using the 'Great Real Estate' plugin which allows shortcodes like [lme-module="schools" city="atlanta" state="ga"]

    I want the widget to dynamically fill-in the city based on the post title(which I can name the city)
    Then I don't have to manually do the shortcode for each city, which also require multiple sidebars to use on the different post pages. I can have 1 sidebar template and use it for all my cities.

    *I tried to use get_tile from the codex but was unsuccessful.

    Can this be done relatively easy or will it require coding to the plugin itself?

    Thanks in advance

  2. Doodlebee
    Posted 2 years ago #

    Yes, you'll have to edit the widget to pull this off. (And get_the_title() won't work because 1) you have to echo it, and 2) it's not in the loop)

    Alternatively, if you just want it to appear at the top of the sidebar always, you can just edit your template file (that way you don't have to worry about it being overwritten if you update the plugin). Open up sidebar.php and put in something like:

    $title = get_query_var('post');
    echo $title->post_title;

Topic Closed

This topic has been closed to new replies.

About this Topic