I develop in ASP.NET MVC so please forgive my lack of the basics when it comes to PHP and WordPress. We have a WordPress site where the terms and conditions link in the footer is broke on one page but works on another.
On our home page (http://www.ourdomain.com) there is a link and when I hover on it I can see in Chrome that it dynamically changes from:
ourdomain.com/wp-content/themes/mm/pdf/Terms.pdf
to:
www.ourdomain.com/wp-content/themes/mm/pdf/Terms.pdf
When I view the source of the page the anchor tag is like this:
Terms
This works fine and renders the necessary pdf file. We have another url (http://www.ourdomain.com/contact) that also has a terms and conditions link that changes from:
ourdomain.com/contact/wp-content/themes/mm/pdf/Terms.pdf
to:
www.ourdomain.com/contact/wp-content/themes/mm/pdf/Terms.pdf
When I view the source of the page the anchor tag is as follows:
Terms
I have access to the entire site and the MySQL database for the site. What can I change to prevent the link from adding content to the URL? Are such links usually stored in the database?
Its because you didn't enter full path so the address is countine from your page address. as you see happend with the contact
/ will point to domain base
./ or empty will point to current url
Examples example.com/contact
<a href="/somefolder/file.pdf">
will point to http://example.com/somefolder/file.pdf
<a href="./somefolder/file.pdf">
will point to http://example.com/contact/somefolder/file.pdf
To avoid this you can enter the full url.
In case of wordpress if the link is in your theme you can use the function get_stylesheet_directory_uri() to get the full url for your theme.
Terms
Related
I am running the qtranslate plugin on my application and I am using get_site_url() for it's various functionalities. below I have two blocks of code. The first one I use get_site_url to view a file that was saved in "/wp-content/themes/seowp/essay_upload/" and it doesn't redirect to http://example.com/es/ however in the second one it does, thus returning a 404 error. These two blocks of code are on the same file.
<?php $file_read = get_site_url()."/wp-content/themes/seowp/essay_upload/".$student_row->attach_essay; ?>
Bearbeiten |
Text to download essay in another language
**This second block of code is used to create a certificate on the fly when clicked using certificat_pdf.php. It is not working correctly like the code above. It even shows the correct URL when I mouseover the link but when I click on it, it redirects to http://example.com/es/certificat_pdf.php?regNoCerts=A00094094 (/es/) being the language specific page and naturally I get a 404 error.Everything works perfectly in english. The only issue is when I view it in a different language. **
<a href="<?php echo get_site_url()."/";?>certificat_pdf.php?
regNoCerts=<?php echo $_REQUEST['regNumber'];?>">Foreign language text</a>
qTranslate is doing what it's supposed to do and is changing the URL of what it sees as a normal page so that the translated version is shown. The first example is not translated as it's not a page on your site.
I'd suggest making a page on your site and changing the certificat_pdf.php file to be a page template within your theme. That way, it doesn't matter that the page URL is translated as the page will still be found.
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)
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.
Not really sure how to phrase my question but here's my issue:
I have a php template type site where the main navigation is in it's own file. Some of the navigation buttons point to anchors on the main page and some go to other pages completely.
My original menu used links like index.php# for the on page anchors and index.php?page= for the off page links. I had two issues with this:
1. When I selected an on page link the page seemed to refresh and it was slow taking me to the place on the page the link was connected to.
2. I'm using htaccess to redirect my url from mydomaincom/index.php to mydomaincom/ and found that my nav didn't work in Safari since my href addresses where index.php#value and Safari v5 wouldn't carry over the anchor links.
Rather than turn off my redirect I just changed the urls to point to mydomaincom/#value. Not only did this work great for all browsers but it also made my page quicker.
Now however when I'm on one of the other pages say index.php?page=photos and I use the nav it just tries to find the anchors on that page (which makes sense but obviously not what I want).
What it's doing now:
mydomaincom/index.php?page=photos#
What I need it to do:
mydomaincom/#
Since the same nav file is used for all pages do I need to create a nave link variable so that when the nav is on a non-index.php page the link urls that hook to the index.php on page anchors uses the full url?
Hopefully this makes sense. Any suggestions? Also trying to keep this search engine/Google friendly :)
Thanks!
While I could have hard coded it I instead created a php variable called $index which I set in the initial settings file loaded first. I set the variable to mydomaincom/# and then updated the nav button links which are onpage anchors to . I didn't need to make it a variable but it means I could change it easier in the future if I need too.
All my nav links that point to anchors on the index.php page are formatted like mydomaincom/# and off page links mydomaincom/page?=. Made sure this worked when using the menu on the index.php page and off pages as well as checked speed and functionality in all browsers.
Thanks!
I've done a lot of small projects on the side lately where the client wants a good chunk of the website to stay the same, they just want to be able to edit particular "areas" of the site. Namely, some text in some box somewhere.
I've found that WordPress works for this pretty well. The interface is nice and friendly to use, and it's got lots of work behind it so I don't have to reinvent wheels, fix bugs, etc.
So what I wind up doing is making PHP pages which look like what the client wants, then making the content editable areas contain a particular post or page, which is what is editable in WordPress.
I'm having the particular page's contents displayed on the page using code like this
<?php echo apply_filters('the_content', $page_Contact->post_content); ?>
where $page_Contact is a variable defined elsewhere.
However, the "Preview" or "View Page"/"View Post" function on each page/post goes to the logical WordPress location and this is not the effect I want in this case.
So for example I have pages like this
www.site.com/index.php
www.site.com/about.php
www.site.com/contact.php
And so forth.
WordPress wants to have the "View Page" and "Preview Changes" links go places like
www.site.com/?page_id=2
www.site.com/?page_id=8&preview=true&preview_id=8&preview_nonce=45522671f5
Which is a problem because, in the permalink structure above, both of those go to the index.php page which, except for the page I'm using to structure index.php, it's not where I want the user/editor to go. And none of the cases above allow any sort of preview (which is a concession I'm willing to make given how I'm doing this)
Is there a way, preferably using a plugin to rig WordPress such that the preview for a page in the dashboard goes to a preview of the non-index.php page where the content will be housed? So for example the link for the "Contact" page in WordPress's dashboard goes to contact.php instead of ?page_id=2? This is a deal where I'm trying to get this done in the editing interface and I'm not concerned about the links in the site itself.
Obviously I would need to maintain this per-page and this would be a situation where new pages don't go up unless I put them there.
Take a look at the preview_post_link hook in WordPress -- it should be called when generating that link, and you can use that in conjunction with a custom field (or some logic) in order to construct whatever preview link you like.
Have you considered page links to plugin for wordpress? Also changing permalinks?