WordPress.org

Ready to get started?Download WordPress

Forums

php text widget code repair (9 posts)

  1. worldesquire
    Member
    Posted 1 year ago #

    I am trying to fix my php text widget code; it should display a scrolling box with contents from a URL on my site (http://worldesquire.com). It is on homepage and shows :404 error page not found.

    Existing code: <div><iframe src="&lt:?php echo home_url ( ): ?>/wp-content/themes/lawfirm/content.html" width= "100%" height="400"></iframe><div>

    URL I want to display: http://worldesquire.com/?page_id=302

    I need help doing it. I can't write code. I don't want to mess it up any more than i already have. Thanks.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    try:

    <div><iframe src="<?php echo home_url( ); ?>/wp-content/themes/lawfirm/content.html" width= "100%" height="400"></iframe><div>

    URL I want to display: http://worldesquire.com/?page_id=302

    in this case, try:
    <div><iframe src="<?php echo get_permalink(302); ?>" width= "100%" height="400"></iframe><div>
  3. worldesquire
    Member
    Posted 1 year ago #

    thanks alchymyth, but it didnt work. it took out, the iframe, the white background, the request box and other things. it also pushed up the bottom section of the page.

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    are you sure you inserted the code into a php enabled content section?

    if not, try to avoid the php code and hardcode the iframe url;

    <div><iframe src="http://worldesquire.com/wp-content/themes/lawfirm/content.html" width= "100%" height="400"></iframe></div>

    (also corrected the closing div at the end of that line to </div>)

  5. worldesquire
    Member
    Posted 1 year ago #

    Alchymyth, I tried out the 1st code you sent again (<div><iframe src="<?php echo home_url( ); ?>/wp-content/themes/lawfirm/content.html" width= "100%" height="400"></iframe><div>) and the iFrame and contents did come on but 1)no white background (90% invisible)and the entire right side bar or column content was moved to the bottom of the left side bar or column.

  6. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    but 1)no white background (90% invisible)and the entire right side bar or column content was moved to the bottom of the left side bar or column.

    this is du to the wrong <div> at the end of the line; change that to a proper closing </div>;
    I corrected that already in my latest suggestion for hardcoding the link;

    here again the correct code:

    <div><iframe src="<?php echo home_url( ); ?>/wp-content/themes/lawfirm/content.html" width= "100%" height="400"></iframe></div>

  7. worldesquire
    Member
    Posted 1 year ago #

    alchymyth, your genius knows no bounds!!! It worked perfectly well and the iFrame is restored and looks way better than before. Thanks a million.

    Any suggestions about how i can change the background of the iFrame text to look like the "light blue background" in right side bar iFrames? Oh, and you are indeed a genius i do declare!

  8. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    try to add something like this to style.css:

    .hentry iframe { background:#f9f9f9; margin-top:20px; }

    or very specific for the one page only:

    #post-5.hentry iframe { background:#f9f9f9; margin-top:20px; }

  9. worldesquire
    Member
    Posted 1 year ago #

    alchymyth Thanks. Where do i find this "style.css" file?

Topic Closed

This topic has been closed to new replies.

About this Topic