PHP content does not switch to other language anymore (Polylang) - php

Hello I m using Polylang and this php code to switch my slider (I did with Smart Slider) to english-french. I don't know anything about PHP but I got it on a forum. It was working perfectly until yesterday.
http://www.chooseyourtelescope.com/
<?php
$currentlang = get_bloginfo('language');
if($currentlang=="fr_FR"):
?>
<div>
<?php
echo do_shortcode('[smartslider3 slider=6]');
?>
</div>
<?php else: ?>
<div>
<?php
echo do_shortcode('[smartslider3 slider=4]');
?>
</div>
<?php endif; ?>
Now it stays in english. I dont think the problem is coming from Smart Slider. I tried to deactivate the other plugins and to restore the previous theme and Polylang versions but nothing changed.
BTW my site is responsive and the slider is not displaying under 800px width. So you can't see the problem on mobile for example.

Instead of doing it with php I resolved the problem with css: I put both english and french sliders in my header template with different classes and "display:none" the slider I don't want for each frontpage:
.page-id-94 .smartslider-en {
display:none;
}
.page-id-7386 .smartslider-fr {
display:none;
}
Please answer if you find a solution with php only.

Here s the solution :
<?php if(get_locale() == 'fr_FR') : ?>
Actually the "get_bloginfo('language')" function stopped working since I upgraded to WordPress 4.6 and to Polylang 2.0.3.

Related

PHP - Hide Element Only On Home Page - WordPress Site

In my footer.php file, I have this bit of code towards the end of the file:
<?php wp_footer(); ?>
<div class="website-by">
<br>
Website by Gateway Web Design
</div>
</div>
</body>
As you can see, I've created a "website by" link, which links to another website when clicked on.
But I don't want this text, or the div that contains it, to appear at all on the home page of the site:
https://thehamburgercollection.com/
I've checked other stackoverflow articles that suggest doing so with JQuery, which I've added to my scripts.js file:
//hide link on the home page
document.ready(function() {
if (window.location.href.indexOf('https://thehamburgercollection.com/')) {
//Hide the element.
jQuery('.website-by').hide();
}
});
And I've also tried hiding the div on the home page with CSS that was suggested here:
.home .website-by {
display: none;
}
But unfortunately neither of these methods have worked. I've declared my class as website-by in the footer.php file, and have added the JQuery that should target that class in the scripts.js file, and have also added the suggested CSS. Any idea why either the JQuery or CSS code isn't working?
This is a WordPress website and a custom there. Any help / suggestions / education is appreciated!
I'm not a WordPress guru, but have you tried doing an if condition in the footer.php? if I got your question right, you need the .website-by to not appear elsewhere but the home page. Maybe something like
<?php wp_footer(); ?>
<?php if (!is_home()): ?>
<div class="website-by">
<br>
Website by Gateway Web Design
</div>
<?php endif; ?>
</div>
</body>

How to remove footer powered by in OpensourcePOS?

I wonder how can I remove footer option saying "Your are using Open Source POS Version blah blah". I've already tried to edit files but after saving and restarting server UI get blocked. that means we can't change in footer. is there anyway to edit this option without blocking UI?
Please Just add this in application/views/partial/header.php
<script type="text/javascript">
$(document).ready(function() {
$('.blockUI').remove();
});
</script>
Problem Solved :)
The footer signature "You are using Open Source Point Of Sale" with version, hash and link to the original distribution of the code MUST BE RETAINED, MUST BE VISIBLE IN EVERY PAGE and CANNOT BE MODIFIED.
Better leave it as it is. Someone went through a lot of trouble making it work, and lets you use it for free. Donate instead of altering stuff you are not supposed to touch.
Its against the license terms to remove the footer. It is always professional and to credit someone's work and effort. Anyway you just need to open application/views/partial/footer.php and remove the following code:
<div id="footer">
<div class="jumbotron push-spaces">
<strong><?php echo $this->lang->line('common_you_are_using_ospos'); ?>
<?php echo $this->config->item('application_version'); ?> - <?php echo substr($this->config->item('commit_sha1'), 0, 6); ?></strong>.
<?php echo $this->lang->line('common_please_visit_my'); ?>
<?php echo $this->lang->line('common_website'); ?>
<?php echo $this->lang->line('common_learn_about_project'); ?>
</div>
</div>

Visual Composer boxed view

I haven't been working with Visual Composer for ages. So my problem is I don't even know how to set up my page.php properly.
I am creating from scratch. I have Bootstrap included and the newest version of Visual Composer installed in my wordpress. I want to have this option:
https://www.youtube.com/watch?v=rkDYWXwQIJg
As for now my content is always fullwidth. I want my content to be in boxed view but have the option to stretch the rows like in the video. My page.php so far looks like this:
<?php
define('THEME_TEMPLATE', TRUE);
define('IS_FULLWIDTH', TRUE);
get_header();?>
<div id="contentarea">
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
</div>
<?php get_footer();?>
So I would appreciate your help. How should my page.php look like if I want to achieve the look of the video. Thanks in advance.
If I'm getting you correctly you want to achieve the stretch row facility of Visual Composer.
In that case your contenarea div should have the boxed width in css -
#contentarea {
width: 1170px;
overflow: visible;
}
Also the contentarea's overflow should be visible since Visual Composer used to overflow the div when in full width.
I hope this helps.

Hiding a PHP element using css (WordPress)

I'm working on a website for a friend, everything goes well so far, but there's one little thing I can't seem to figure out.
I have included SmartSlider 2, which I want to hide on mobile devices. But since SS2 doesn't natively support this I tried by editing the code. Long story short, it won't work.
I've tried including the CSS in the file itself (header.php) :
<div class="slider" style="#media(max-width:1120px;){.slider {display:none;}}">
<?php echo do_shortcode('[smartslider2 slider="2"]'); ?>
</div>
For some reason, it still shows up, hopefully you guys can help me out. Thanks in advance.
It will not work like you are trying.
you have to put this in custom css
#media screen and (max-width: 1120px) {
.slider {
display:none;
}
}
and remove from here
<div class="slider">
<?php echo do_shortcode('[smartslider2 slider="2"]'); ?>
</div>
and in media query CSS you have ; here #media(max-width:1120px; it's wrong
Fiddle

How To Select Template Based On Language Switch?

I have a Joomla 2.5 multilanguage website and I want to have a different banner on the English version and on the French version. I know that I can duplicate the template and assign them to the specific language but I am doing a lot of modification in the CSS and I don't want to double the changes!
I did add this condition in my index.php but only the first banner will display on the EN and the FR website.
<?php if ($this->language = 'en-gb') : ?>
<div style="background-image: url(/templates/mega_calibra/images/bannierEN.png);"></div>
<?php elseif ($this->language = 'fr-fr') : ?>
<div style="background-image: url(/templates/mega_calibra/images/bannierFR.png);"></div>
<?php endif; ?>`
What am I doing wrong?
Basic PHP error
if ($this->language == 'en-gb')
I think $this->language will return en-GB and fr-FR (note the uppercase) so check with a var_dump() on $this->language.

Categories