Some wordpress php, link, language questions - wordpress

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();
} ?>

Related

Why is the_content() (and get_the_content()) unstyled in my WordPress page?

I'm absolutely new to WordPress theming but I decided to learn on the job and I really want the site to go live within the next week or so. I've stuck to a simple index.php (no templates or template-parts). I'm able to receive the contents in the proper format which they were published (with inline images, line breaks, etc.) but the css styling is absent. What could I be doing wrong?
<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<div class="entry-content">
<?php
$content = wpautop(get_the_content());
echo $content;
?>
</div>
</article>
I realize there is a difference between the singular view and the list view (the loop). The list view doesn't actually style the content by default. Could that be where my problem lies, and if so, what's the best way to get around this problem?
EDIT
Essentially, I want the singular view (singular.php) within the index.php. When you visit the site you're greeted by an entire article, not previews and listings. So I don't actually need the loop for now. I simply retrieve the post and display the contents on the index page.
That is literally the only thing keeping my site from going online right now. I just need that article to be styled as it's supposed to be. There are only two files in my theme: index.php and style.css. I've already tried the_content(), I've also tried apply_filters('the_content', get_the_content()), to no avail. wpautop(get_the_content()) was the closest thing to styled I could get. I am retrieving the post using the_post() for now, could that be the issue, and if so, which is the best way to retrieve a post?
I have tried retrieving the post in various ways and it's still unstyled, so I decided to inspect the elements in the browser and found that WordPress is indeed attaching a class to the elements but just where on earth is that class? I read somewhere about a css reset being the possible cause -- how does one bypass any css reset issues?
It turns out it was just a header issue. Solved by adding:
<head>
<?php do_action('wp_head'); ?>
</head>

Different header.php for mobile devices on wordpress?

First of all: sorry for my bad English, I'm from Germany.
I've got a big problem in my wordpress homepage with the header on mobile devices.
The site is: www.hd-sign.de
If you open the page on a computer, everything looks fine, but if I open the page on a mobile device, the text box on the left is over the "HD - Sign" text and it looks very bad.
You can see what i mean on "am i responsive".
I installed the Mobile Device Detect Plugin to Wordpress and added this to my custom.css file:
include Mobile_Detect.php;
$detect = new Mobile_Detect;
if( ! $detect->isMobile() {
include "mobile_header.php";
}
else {
include "header.php";
}
But it wont work. For sure I installed the header.php & mobile_header.php (without the boxed text) to my main theme folder.
I tried many different methods in the past 5 hours but I still was not able to fix this problem.
Thank you very much in advance for every answer!
EDIT:
Thanks for every answer, actually i got the following code:
include Mobile_Detect.php;
$detect = new Mobile_Detect;
if( ! $detect->isMobile() ) : {
function get_header( 'mobile' );
}
else : {
function get_header();
endif;
}
Im not sure if this code is correct and absolutely not sure if i have to put the code in the "general-template.php" or in my custom css. Sorry for this stupid question, but i just started working with html and css.
It would be great if someone can tell me where i have to put the (correct?) code!
Thanks!
Name your files like this:
header.php
header-mobile.php
and use WordPress conventions to call your headers like this:
// default
get_header();
// mobile
get_header( 'mobile' );
Other than that, I'd highly recommend looking into responsive web design and media queries. Your header will load once when the page loads for the first time. It won't change when you resize the browser window by using this technique.
Resources:
WordPress function reference for get_header() - http://codex.wordpress.org/Function_Reference/get_header
Try this.
if(!preg_match('/(iPhone|iPod|iPad|Android|BlackBerry)/i', $_SERVER['HTTP_USER_AGENT']))
{
include "mobile_header.php";
}
else
{
include "header.php";
}

wordpress get current permalink or url without domain

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

Wordpress adding thumbnails to category

How to take on a problem in WordPress admin editing.
I'd like to edit an edit-category admin panel to add a featured image to it (just like in posts), but I'm a bit indecisive since a lot of people use a custom field with static path to a photo, but I'm wondering is there a way to do it better(enable some wp hook and such).
Can someone point me in the right direction?
Thanks for the plugin it seems good, but i have one additional problem. It seems i have a lack of knowledge on how to query an object [category] so i can apply filters, hope im making some sense. This is done on my home.php. all dumps are null
<?php get_header();
$listcat = get_categories('hide_empty=0');
foreach($listcat as $x){
$img = apply_filters( 'taxonomy-images-queried-term-image', '');
var_dump($img);
}
get_footer(); ?>
The same code works with no problems if i stick it in category.php. Any ideas? :)
i've used several times the plugin "Taxonomy Images". it works with multi-language wp installs too.
link with instruction: http://wordpress.mfields.org/plugins/taxonomy-images/

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.

Resources