• sacconi

    (@sacconi)


    This code is not working:

    $output2 = '<form>';

    $content2 = ' "<a href='".get_permalink( get_the_ID() )."#my_map_123'><img src='/wp-content/uploads/2023/07/map-3.jpg'/></a>" ' ;

    $content2 = $output2 . $content2 . '</form>';

    echo $content2;

    The code is inside php tags

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator threadi

    (@threadi)

    What does “not working” mean? Syntactically, it is correct, but the structure is wrong. However, this should not lead to errors.

    Thread Starter sacconi

    (@sacconi)

    I got a permanent error, so, what is wrong in the structure? I need a button, when I press the button the visitor is guided directly to the map related to that apartment

    Moderator threadi

    (@threadi)

    I just noticed that you mixed up the quotation marks in the code. That’s what’s causing the error.

    If you just want a button, the following is all you need:

    echo '<a href="' . get_permalink( get_the_ID() ) . '#my_map_123"><img src="/wp-content/uploads/2023/07/map-3.jpg"/></a>"';
    Thread Starter sacconi

    (@sacconi)

    …I’ve seen that I mixed 2 codes, I just needed an image with a link, so I’m using

    echo "<a href='".get_permalink( get_the_ID() )."#my_map_123'><img src='/wp-content/uploads/2023/07/map-3.jpg'/></a>" ;

    how can I style it? using a <span ID: “xxx”> ? the tag span goes after “echo”? – thank you

    Moderator threadi

    (@threadi)

    When you talk about styling, I would expect a solution using CSS. For example, you can assign colors to a link as follows:

    a { background-color: red; }

    Of course, you would also have to address the button directly, so give it a class:

    echo '<a class="button" href="’ . get_permalink( get_the_ID() ) . '#my_map_123"><img src="/wp-content/uploads/2023/07/map-3.jpg"/></a>';

    and then address it via CSS as follows:

    a.button { background-color: red; }

    Of course, I don’t know what kind of display you want to use at this point. CSS offers a wide range of possibilities, so there is no need to inflate the HTML code.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Error in my php code’ is closed to new replies.