Wordpress: How to build a link with php-function call? - php

I want to add a logout link to my wordpress page.
Logout
The link is visible on the page but when i click it it redirects me to
https://www.mywebsite.de/%3C?php%20echo%20wp_logout_url(%27https://www.mywebsite.de/%27)%20?%3E
which of course result in a 404. Obviously the php code is not executed. What am i doing wrong? How can i build the link dynamically?
EDIT:
I want to place this link via wordpress dashboard to the navigation menu (Appearance -> Menus -> Costum Links). For a first try i just added the link to my front page (Pages -> All Pages -> Choose Front Page --> added link in editor to page content).
In booth cases the php code is not executed but added to the link which results of course in a broken link (404).
The control characters like "<" get substituded. The whitespaces too. Maybe it is a character encoding problem?

Logout
https://developer.wordpress.org/reference/functions/wp_logout_url/

The problem was that is not possible to execute php code in wordpress editor (which is a good thing due to security reasons).
So i found another way: I created a shortcode for generating my dynamic link/url. With the plugin 'Shortcodes in Menus' everything works just fine.

Related

Wordpress: changing only one page url from database

In Wordpress I created a page "home" (https://sitedomain.com/home) but I cannot render it equal as the homepage (I made a page template equal to index.php and implemented the custom query but still not working properly).
I currently have a
echo("<script> window.location.replace('https://sitedomain.com')</script>"); statement in the single page template file allowing me to redirect users to the actual homepage but it is slow. I want to manually change the URL of this page in the database but I cannot find it in the Database.
Also, it is not possible to modify the URL from the dashboard since the minimum url must be https://sitedomain.com/home.
Is it possible? Where to find the single URL of the page in the Database?
You can just define that page as your homepage in the WP dashboard: "Settings > Read > select static page as starting page" (or similar, not sure about the exact English terms)
in the end I simply used JQuery to replace the href attribute with the one that I needed (https://sitedomain.com).
Not ideal solution but it works.

Wordpress Permalink Issue Remove Auto Added Code

I have a Website of Wordpress In My Website When I click on any URL After complete Loading Content Page Some Codes Automatically Add on Permalink
For Example
http://example.com/wow-amazing/ Correct Link This Link Is Fine
After Complete Page Loading
http://example.com/wow-amazing/#.WfB5iI-Czcs
How Can I Remove #.WfB5iI-Czcs this Automatically Added Code From Permalink
Thanks In Advance
That part with # is generated at front side, so it actually doesn't affect you permalink. So there is no problem if you see that.
And actually it doesn't come from permalink, it is generated by some plugin's javascript. (for example AddThis generates such anchors, if you use AddThis, then the reason is AddThis)

Strange link bug with hyperlink in Wordpress

When I clicked on link that redirects to Main Shop page of WooCommerce, there is blank page with no products. (see link ПРОДУКТИ in top right bar above the header)
When you click on button from Main Menu it is OK (button: ПРОДУКТИ).
I disable all plugins and change the theme, but with no luck!
See here my website Shop page: https://www.mangustaceramics.com/продукти/
Example of the problem: http://i.imgur.com/KcGSK10.jpg
If you have any suggestions about the problem, I will be glad to hear them! Thank you!
These are technically different links. You can see this by copying the URL from the address bar and pasting them in a text editor.
The top right bar link gives this output:
https://www.mangustaceramics.com/%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D0%B8/
Whereas the main menu one gives this:
https://www.mangustaceramics.com/%d0%bf%d1%80%d0%be%d0%b4%d1%83%d0%ba%d1%82%d0%b8/
You will need to ensure that your URLs are encoded correctly or specify them explicitly using the second link above (with lowercase letters).

Anchor tag not working in Wordpress

The first thing is that the code is written in HTML and now I am changing this code in Wordpress. I have a home page where I have created a top menu which has links to several other pages.
This is the code I used to link it:
facilities
This was working fine when I was doing in in HTML, but it's not working when I am opening my page in localhost. When I click it, it shows a message that no content is found.
You need to add base url at first. For wordpress, you can do this with get_template_directory_uri().'/facilities.php'
Here, i assumed 'facilities.php' is located on your base directory if there is more directory you need to add those too. Hope, it helps.

Wordpress - only the homepage can be found

My wordpress site works perfectly. My pages I create in Wordpress admin panel are displayed in widgets, so if you click on a nav menu item, a div appears and displays the content of it. Perfect. But as soon as I would like to write a new .php page and try to open it like writing "mywebsite dot com / confirmation.php" in the address bar, the bar displays "mywebsite com / confirmation.php" but there is the front page on the screen again. Even if I write anything else after mywebsite dot com/, it shows the index page, no matter what it is.. I tried to write "mywebsite dot com/sdjfhskhdfkshdfkjhsdf" and it still worked, displayed the home page again.
Any ideas?
Save your permalinks and make sure your htaccess is writable when you do so. Also can you get to your "/confirmation" page if you click view page from inside the page in dashboard? Also try changing the template that your new page is using.

Categories