Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30858
    adamsp
    Guest

    I would like to add some custom HTML to the widget area above the site title in the Florentine theme. I would like to display the page title there, right justified in that widget area, but I have no idea how to reference the page title. Is this possible and if so, how would I do it?

    #30859
    support
    Guest

    Thank you for your question, our team is happy to help!

    Creating a dynamic widget that changes the text it displays based on the current page requires the use of some PHP code in addition to HTML to function as expected.  The caveat here is that the WordPress standard widgets that are contained in our themes are not intended to handle this kind of custom coding.

    However, I was able to locate a plugin that adds a PHP Code Widget to the list of available widget that will allow you to execute PHP code in it.  WordPress has a reference library of all the available PHP functions that you can use to retrieve information from your website, including Post/Page titles.

    I installed the PHP Code Widget in one of my test installations and created a quick snippet that should give you the functionality you are looking for.  Here is the snippet in case you want to try using it:

    <h2 style="text-align:right;"><?php echo get_the_title(); ?></h2>
    

    That snippet will retrieve the title information for the current page or post, dynamically adjust the HTML text to correspond to the page, and aligns itself to the right.  I recommend trying that code out in a testing installation before implementing on your live website to make sure that it works correctly, but hopefully that helps you create the design you need.

    Please let us know if there is anything else that we can do to assist you, we are always happy to help!

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘How to Add Page Title in Widget Above Site Title in Florentine Theme’ is closed to new replies.