How to link images and pages in wordpress pages? - wordpress

So, in the WordPress page, I need to link the pdf in wp-contents so I linked it with the relative URL as href="/wp-content/uploads/2017/03/test.pdf"
when I click it since my root in localhost is localhost/test it takes me to localhost/wp-content/uploads/2017/03/test.pdf (which doesn't serve the file). However, I don't think it'll be an issue in the server. Still, I want to know if this is the correct way?
Also, so I'm in page localhost/test/page22 Now on the page, I have an anchor tag as href="/page23" it takes me to page23 correctly, but when I'm in a different sub page say localhost/test/page/page2 now, the link takes me to localhost/test/page/page23 which is not correct as it should be localhost/test/page23. How can I solve these issues

WordPress provides functions for getting the URL of resources you should use these instead of having your code generate the URL. In this case you should call wp_get_attachment_url().

Related

GitHub Page Custom URL Styling and Pics don't render

My site, Jekyll static pages and a blog, https://omnebonum.github.io/dsu/ on GitHub pages looks like it is supposed to (such as it is). I have a custom URL set up that points the repo to democracystraightup.org. That works but when I go that URL the pages show up without any CSS or pics.
I know this isn't super specific information, but you can check them both out if you like, and any general insights would be appreciated.
All your css, javascript and other assets are returning 404 errors:
The paths are all pointing to subdirectories of http://democracystraightup.org/dsu/ (e.g. http://democracystraightup.org/dsu/js/gallery.js).
Thats wrong.
You need to drop the /dsu to make it work.
For example http://democracystraightup.org/js/gallery.js works totally fine.

Absolute external links bug, url of the current page added at the beginning of the url

I have a very strange external links behavior on this page:
https://dev.switchonpaper.site/en/daniel-g-andujar-the-artist-as-a-thinker-and-augur-of-what-happens/
There is a list of external links visible by clicking on "Go Deeper".
On some links, the address of the current page is added at the beginning of the external link.
E.g.: iSAMâ„¢ (1997)
E.g.: TTTP Photo Collection - 1997
All external links are absolute links.
When you look at the source code, the links are correct.
This site runs under Wordpress, the links are contained in a Gutenberg block built with the ACF plugin.
I tested the following things:
Disable all plugins.
The browser or something else continues to add the current page address on some links only.
I emptied the server cache, removed all the .htaccess rules except the wordpress part.
I made sure that the PHP file that writes these links is in UTF-8.
By recreating the links, it is always the same ones who are affected.
Does anyone have any idea what could cause this?
Thank you for your time and help!
You have the so called "hidden characters" before your link start. I suggest you to check it by yourself with some online tool like this: https://www.soscisurvey.de/tools/view-chars.php. If you try to paste there the link copied by your source code you will see you have hidden stuff before "https:..."
The solution to this issue is that you delete all the characters and you write them all over again by yourself, w/o copy/pasting them from another source or in alternative paste them inside some non-HTML text editor before pasting them to your website

redirect to a page is not working properly in asp .net which is inside sub folder

I have sub folders says X,Y,Z. I'm making menu list dynamically using 'ul', 'li' tags based on user rights. Inside 'li' tag i have 'a href="#"' tag. The tag 'a' filled from database dynamically.
The problem is the tag 'a' has link X/home.aspx. When i click first time this works since it is available. second time 404 page not found error arising. The link become X/X/home.aspx. Obviously this structure is not available. So, how to redirect.
Thanks
I don't know exactly how your href is continually being added to in this specific scenario (it's a bit of a pitfall in a number of areas, sometimes when using custom controls, etc.), however, you should qualify all of your links from the root by using a prefixed forward-slash (/, i.e. /x/home.aspx).
But we're not done, ASP.NET can transform these too, in other scenarios, so you might want to use the tilde+forward-slash prefix (~/, i.e. ~/x/home.aspx); this indicates the root of the virtual directory where the site is housed.
In this way, regardless of which level of the sites directories you are in, the links always refer to a full path, so to speak.
Your hrefs are relative from the page not from the root of your site...
So do not use "x/home" but use "/x/home".. or use "~/x/home"
Probably you are appending the directory.
If you click for 3rd time you get X/X/X/home.aspx?
Post your code in order to get more help.
Use Page.ResolveUrl
Page.ResolveUrl("~/x/home.aspx")

base URL problem

in my Drupal site
http://www.revdup.co.uk
I recently changed the domain name, I had to change a few absolute URLs and everything seems to be working fine now, except the front page, and only when I am logged in, not as a guest..
for some reason all the theme images (such as those used to build blocks appearance) are using an incorrect version of the base URL eg:
revdup.co.uk/revdup/themes/drupal_pwc010_tech/images/Block-s.png
instead of:
revdup.co.uk/themes/drupal_pwc010_tech/images/Block-s.png
I have changed the base URL variable in settings.php
Why is this only happening on one page and how can I fix it?
You'll need to explicitly clean the template cache. Go to Administrator->Themes->Selected theme->configure->Save.
This will regenerate the template cache with correct urls. Also clear the drupal cache in Admin/settings/performance.

Image disappear when url route

I am writing a web page to show image (image is dynamically generate by .Net charting) in a web. I have used the asp.net web forms URL routing to navigate to this page. Once I use the URL routing the image appear on the page. Anyway this is working fine for normal page browse.
More than likely your link to the image is using a relative path, and once you introduce routing you are working with a URL structure that appears to be deeper nested in the folder structure than it is.
When linking to the image for display I would recommend using root relative path something like /Images/MyFile.jpg rather than ../Images/MyFile.jpg, or similar.
This way if your route changes, and additional "folders" appear in the route, the link will still work.

Resources