• aclassifier

    (@aclassifier)


    I would like a plugin or some CSS code or something like [wpbsearch] to cause, on all my posts and pages, the true URL of that page to be displayed. Update; not like [wpbsearch], because then I would have to edit each page.

    The rationale for this is that it apears to me that if a page has been arrived at through (like) Google search, then the whole search string (some times?) appears in the browser. If one then want to send that page identification, it’s a Google “paragraph” that appears, not the true link.

    My question is a suggstion to resolve this. But any better idea would also be appreciated.

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

Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi @aclassifier

    I hope you are doing well today.

    In such a scenario, it will be good to create a child theme and in the correct place, like the header, footer or your page template, implement this code:

    global $wp;
    $current_url = home_url( add_query_arg( array(), $wp->request ) );
    echo $current_url;

    Also, you can close this code in a div and adjust the CSS so it will look better in the place where you will put it.

    Kind Regards,
    Kris

    Thread Starter aclassifier

    (@aclassifier)

    Thanks, @wpmudevsupport13 !

    I already have a style.css under Twenty Twelve. It’s at https://www.teigfam.net/oyvind/home/wp-content/themes/twentytwelve-child/style.css

    I added your code at the bottom. But how do I put it inside a header type?

    • This reply was modified 1 week ago by aclassifier. Reason: typo

    Hi @aclassifier

    The code I have shared above, should be placed in php file as this is PHP code. It will not work in CSS file. You need to edit one of the child theme files and place it in php tags to make it work.

    When it comes to CSS, you can close that code in HTML tag, like div for example, use custom class and by using that class, adjust the design.

    Here is some example:

    PHP file

    <div class="your_custom_class">
    <?php

    Your PHP code

    ?>
    </div>

    CSS file

    .your_custom_class {}

    Kind Regards,
    Kris

    Thread Starter aclassifier

    (@aclassifier)

    Thank you! Will any .php file in the directory /twentytwelve-child just be included when all pages or posts are loaded? Could I use functions.php, which now contains only this line:

    <?php add_shortcode('wpbsearch', 'get_search_form'); ?>

    In case yes, I assume that your code

    global $wp;
    $current_url = home_url( add_query_arg( array(), $wp->request ) );
    echo $current_url
    ;

    will need to be told that it should be drawn with the header?

    In case no, what should the file be called in order for that code in it be included when he screens are drawn?

    Kind regards,
    Øyvind

    • This reply was modified 5 days, 23 hours ago by aclassifier.

    Hi @aclassifier ,

    I hope you’re doing well.

    Will any .php file in the directory /twentytwelve-child just be included when all pages or posts are loaded?

    Not exactly, for a .php file to work, it must either be a recognized template, explicitly included, or hooked into WordPress’s execution flow.

    Here is more info about WP Child Themes – https://developer.wordpress.org/themes/advanced-topics/child-themes/

    In case yes, I assume that your code

    will need to be told that it should be drawn with the header?

    In case no, what should the file be called in order for that code in it be included when he screens are drawn?

    You can add the code directly to your header.php file on the theme in case you need it on the header, or just use a plugin like https://wordpress.com/plugins/insert-headers-and-footers

    If you are going with the plugin, please create a backup first and use the PHP option when adding the PHP code.

    I hope this helps.
    Best Regards,
    Williams Valerio

    Thread Starter aclassifier

    (@aclassifier)

    Thank you!

    I have now inserted the WPCode extension. I added this code as below as “Site-wide header”

    <?php
    global $wp;
    $current_url = home_url( add_query_arg( array(), $wp->request ) );
    echo $current_url;

    This seems to work, displaying it on the very top. However I would like to print it is a clickable url. But the below code prints first the url then the clickable url. And Duck.ai couldn’t help me any more. It said that if it printed more than the clickable url there might be something else that interferes.

    Test it here: https://www.teigfam.net/oyvind/home/ or any other page. It’s on the top. How could this be done?

    Once I get this right, is there any way to place it below the heading picture?

    I don’t know the escape characters here, so I had to make a bitmap of the code.

    Thread Starter aclassifier

    (@aclassifier)

    Forget the double-print above. With two echo that code certainly double-prints! How blind can I be?

    But the placement question is still valid. I have centered it on the top now. (I will also do this on desktop only. That was Pro only.)

    • This reply was modified 4 days, 19 hours ago by aclassifier. Reason: More info
    • This reply was modified 4 days, 19 hours ago by aclassifier.
    • This reply was modified 4 days, 19 hours ago by aclassifier.

    Hi @aclassifier,

    I see the URL is now clickable. To place the URL below the featured image, can you please try switching the location of the code to “Site wide body”, which should insert the snippet just after the opening body tag.

    https://ibb.co/dJKjDYCp

    I hope that helps.

    Best Regards,
    Nebu John

    Thread Starter aclassifier

    (@aclassifier)

    Hi @wpmudevsupport14

    I have now updated from “Site wide header” to “Site wide body”, but it seems to me that it’s on the same place, on the very top. I have purged all cached files in WordPress and emptied all buffers in Safari (18.6 on macOS Sequoia). I will not experiment with any other option, let it stay like that until I might hear from you.

    Best regards,
    Øyvind

    • This reply was modified 4 days, 1 hour ago by aclassifier.

    Hi @aclassifier

    Seems like “Site Wide Body” won’t help, can you change the location from “Site Wide Body” to “Page-Specific” in the plugin side and see if that helps?

    You can test with “Insert Before Content” or similar and see whether that helps?

    Please do let us know how that goes.

    Regards,

    Nithin

    Thread Starter aclassifier

    (@aclassifier)

    Hi, I found no  “Insert Before Content”. There is the proximity placement for css / html, but that’s for Pro. Where might what you mean be? I did not change anything.

    I don’t do this in “Global Header and Footer” page but in the “Edit Snippet” page.

    • This reply was modified 3 days, 21 hours ago by aclassifier.
    • This reply was modified 3 days, 21 hours ago by aclassifier.

    Hi @aclassifier

    Did you try to create a child theme and use the code in the child theme template as mentioned here:
    https://wordpress.org/support/topic/page-url-to-be-displayed-on-the-top-of-each-post-or-page/#post-18730210

    Kind Regards,
    Kris

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

You must be logged in to reply to this topic.