wordpress get current permalink or url without domain - wordpress

I'm not sure if I titled this correctly but this is my issue, I have to create 2 same exact blogs and the only difference is language. So but what I need is at the top when clicked on a language it would take the user to that same page but in the language he/she clicked on.
I'm using permalinks currently and I've tried the following:
<?php
function my_permalink() {
echo substr(get_permalink(), strlen(get_option('home')));
}
my_permalink();
?>
but that for some reason on my home page points to a post and not the home page. I believe that works in posts but I need that to also work on the home. Here's the links to both blogs, any help is much appreciated..
English: http://www.inblu.pe/prblog/
Spanish: http://www.inblu.pe/prbloges/

It could be more simple with standard PHP method :
$_SERVER["REQUEST_URI"]
Of course it will work for current post only.
You can also use that :
<?php
function my_permalink() {
echo substr(get_permalink(), strlen(home_url('/')));
}
my_permalink();
?>

How about the_permalink? I'm fighting with that now.
~ Justin

Related

SEO & WordPress: Changing category links manually

I'm not too sure about SEO on WordPress as I read somewhere (I think) that Google penalises category pages for duplication and was hoping someone could tell me whether or not it's a good idea to cut out the links to the category pages all together?
My permalink structure for my main navigation does not link to the category pages. I have created a page specifically for tutorials like so:
myurl.com/tutorials/tutorial-type
and then on the pages there is an if-statement that gets posts from a specified category for that page.
so myurl.com/tutorials/tutorial-type will get only posts in the tutorial-type category.
What i'm planning is instead of using the:
<?php the_category(', '); ?>
in the typical Posted in: Tutorials format under the title of the post to a quick function that will direct someone to the main page for that category. like so:
function changeCategoryToPage() {
if (in_category( 'tutorial-type' )) { ?>
Tutorial Type
<?php }
}
I would appreciate your feedback and wisdom :)

Some wordpress php, link, language questions

I have recently start using Wordpress for the very first time and i have to say it is going well. i previously made my own theme with the bootstrap 3 framework and started to implement it into wordpress.
I came across allot of things i didn't really find a good answer for.
first of all i want my website to be multi language (Dutch & French) for that I've installed qTranslate that works very well. But on the other hand that also gave me the problem that i had to include my header and my footer into my html editor in Wordpress because the text there has to be multi language, where normally just the content is placed. Anyone els is experiencing that problem or maybe knows a walk around for this?
My website contains allot of PHP because there is a payment system that is implemented into it, so i constantly need a connection to my database (MYSQL) and also am working with sessions. I'm not so far yet, tomorrow i will but can i just implement my PHP code into the well known tags <?php ?> and place them into the html editor in Wordpress?
So like you already know i had to put my header into the html editor in Wordpress but now i am facing a problem linking to my home page. If, in my navigation menu, i want to link to home i cannot use for example : <?php echo home_url(); ?> and i f i just use <a href"home"></a> it also doesn't work...
Appreciate for the help!
I figured out how I can include different header & footer (header-fr.php, footer-fr.php). I used this code:
<?php
if(function_exists('qtrans_getLanguage')) {
$lang = qtrans_getLanguage();
switch ($lang) {
case 'fr':
get_header('fr');
break;
default:
get_header();
break;
}
} else {
get_header();
} ?>

Permalink-safe way to link pages inside footer.php

I am currently building a new theme for my site and am kind of stuck not knowing the proper way to link pages together. What is the proper way to direct visitor to another page if I were to write the link straight into footer.php?
Let's consider the following inside footer.php:
?>
A Link
<?php
That would work well up until I were to change my permalink structure to something else.
What is the proper way to do it(without using WP built in menus or anything similar)?
You can use get_permalink assuming your pages are in Wordpress.
See this link: http://codex.wordpress.org/Function_Reference/get_permalink
The above answer is 100% correct, but to save people some time when they stumble upon this question, I took the liberty of writing it out.
<?php echo get_the_title(12); ?>
This covers everything from hover text to dynamic page title, so if you decide to change "Contact" to "Contact Us," you won't have to remember to update the footer.php file.

Wordpress' Contact Form 7 returns 404 but works on homepage

I've installed Contact Form 7 (v 3.1.1) into Wordpress (v 3.3.1). It works fine on the homepage (which is a static Page called 'Home') but on any other page it does nothing and the console says:
POST http://trademarkshop.ca/contact/ 404 (Not Found)
I'm using do_shortcode to call it from both theme files:
<?php echo do_shortcode('[contact-form-7 id="212" title="Contact form"]'); ?>
I have wp_footer() in the footer and wp_head() in the header. I have no other plugins installed. I've even checked for if(is_home()) restrictions. I also tried re-directing other pages to use the Home page template file, but still gives a 404 error.
I've never had this problem before. Any ideas would be very appreciated!
have you tried changing your permalinks to something else,
then save,
then change it back to /%postname%/
could be its not creating the htaccess file in the wp root,
hence your permalinks arent working,
Marty
use this code
<?php echo do_shortcode( '[contact-form-7 id="7" title="Contact"]' ); ?>
His problem is caused by a combination of two misconfigurations. First, AJAX JavaScript is not functioning on your contact form. Due to this problem, your contact form needlessly redirects after submission. Second, your contact form uses unavailable words in the names of input fields. This issue confuses WordPress, resulting in the 404 (“Not Found”) error.
https://contactform7.com/faq/my-contact-form-always-redirects-to-404-error-page-after-submission/
Change your Contact form 7 field names. Because some names already using by wordpress may be is conflicting.
Example:
name to username
Sometime that happen cause the code (id) in de form (When you try editing the error message on the left side there is a short html like code on witch there is an id) is not the same as the one when you go to dashboard>contact and the short code entry of the table. You need to change the first one to match the second one

Alternatively presentation of the archive

I'm searching for an alternativ view of the archiv output page.
So if you click on a archiv link you get a view e.g. of the Month.
And exactly this Page where i get the filtered output i want to apply some changes.
So i mean not:
wp_get_archives()
Best regards Illu
If you just want to make a few small changes, then just filter it with the wordpress function is_archive(), e.g.
<?php if (is_archive()) { ?>
Say hello to the archeologist users
<?php } ?>
...otherwise, if you want to have a completly different template for that page, then just create a file called archive.php in your theme directory. Hope I understood your question right :)
Some more resources for the is_archive() function is to be found here - well explained examples. And some more information about template files are here

Resources