I'm using WPML plugin to make my website multilingual and some of the text / button text can't be translate.
I have this code:
<div class="header-left">
<div class="num">
<strong> Call us Now </strong>
+000000
</div>
</div>
I have this block of code in wordpress php file.
How to add this as a string so i can translate it with WPML?
You have to put the text in a function like this :
<?php echo __('Call us Now', 'yourtextdomain'; ?>
or you can just do
<?php _e('Call us Now', 'yourtextdomain'; ?>
Then go to WPML and resync your theme or plugin where you have this text. (There is also an option to do that automatically)
Check the doc to know more :
https://developer.wordpress.org/reference/functions/__/
Related
I m building a word press site with a unique theme that i created, now i got like 10 classes of different styles for the static pages in my site.
The question is, when i want to display the content of the page, with all the forms images and text, how should i do that? With the text editor where the user usually insert his content for the posts in regular wp website? Or should i insert the content images and forms hard coded in the php custom page template of those static pages?
In the text editor if i insert some html in edit as html it's becoming a mess it doesn't seems right to create sections and div where the user regularly just put his raw content, and anyway adding more content to a static page in the future will require my intervention to wrap it with css sections and div's definitions and classes...
By the other hand to write raw data with images and forms in the php custom page template doesn't seems to me the right choice... Is it normal to do so for static pages?
Thanks everyone!
Wordpress static pages, by default contains text and images that you can put into it using the Wordpress text editor. This content is known as "The Content" in WP context.
If you want to put into your static page some elements that cannot be setted by the text editor (like your own forms, per example) you'll need to create your own page template with hard-coded elements.
Example:
<?php /* Template Name: My custom page template */ ?>
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="article">
<div class="date"></div>
<!-- Your own custom content here -->
</div>
<div class="clear">
<?php if ( comments_open() ) : ?><div id="comments"><?php comments_template('', true); ?> </div>
</div><?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php get_footer(); ?>
I normally will put those styles into styles.css of your theme. Even if it's images that will be standard images for the theme or shortcodes available to the user you want it to load from within the styles.css page. You don't want to do anything static like that with WordPress. Updates can mess it up as well as having issues with inline css messing up your SEO for the site.
If the user needs to do something in the editor to have an image show or something like that you can do it as a shortcode. That's normally going to be your best approach. Have you used shortcodes and loaded the images that before?
There seems to be a problem with something on my wordpress page as a widget isn't displaying but I'm not sure how to edit the widget.
The code on homepage.php under Appearance>Editor is
<section class="row post_content">
<div class="col-sm-8">
<?php the_content(); ?>
</div>
<?php get_sidebar('sidebar2'); // sidebar 2 ?>
</section> <!-- end article header -->
Where would I find the code for 'sidebar2' as at the moment an error message appears on the page where the sidebar should display
As outlined in the Developer handbook for get_sidebar(), your sidebar file should be called sidebar-sidebar2.php. This file will be present in the root directory of your active theme.
The get_sidebar() hook allows a specific sidebar template file to be used in place of the default sidebar template file. If your file is called sidebar-new.php, you would specify the filename in the hook as get_sidebar( 'new' ).
I'm using the YARPP plugin for a custom hosted wordpress site. I've changed the default location settings so that it only displays the widget where I specify (see screenshot). When I call the plugin in my single.php file it is moving the widget inside of the article.post, even when I try and contain it in a separate wrapping div.
single.php:
<article class='post'>...</article>
<div class='yarpp-wrapper'>
<?php if (function_exists('related_posts') ) : related_posts(); endif; ?>
</div>
output:
<article class='post'>...</article>
<div class='yarpp-related'>...</div> <!-- yarpp plugin-->
<div class='yarpp-wrapper></div> <!-- empty wrapper -->
I believe it's because you are using a custom yarpp template. Select 'List' instead, leave the other options above unchecked, and make sure the php script is in your single.php file. No need to wrap it in anything. Just place wherever you want it to show.
<?php related_posts(); ?>
Ok I just developed my first custom Wordpress theme using a guide - I'm still a noob. I'm not using widgets to fill the sidebar, I want to fill it myself with my own code and images.
So lets say I want the first sidebar I made to show up only on the homepage, and then the 2nd sidebar I made to show up on every other page. Can I use an if statement?
<?php
if(is_home()){
echo
"<div class="row">
<div class="span3">
<div id="search-box"><img id="search_text" src="http://localhost/Dorsa/wp-content/themes/Bootstrap/img/text_findyourhome.png">
</div>
</div>
</div>
<div class="row">
<div class="span3">
<img class="box_shadow" src="http://localhost/Dorsa/wp-content/themes/Bootstrap/img/box-shadow.png" style="padding-left:0;">
</div>
</div>
<div class="row">
<div class="span3"><div id="news" style="margin-top:275px;margin-bottom:200px">News</div></div>
</div>"
}
else
{
echo
"sidebar 2 code - didn't write it yet"
}
?>
You can use if statement as said by #ChrisHerbert if you just want to display one sidebar in homepage and other in rest of your pages. New solution would be by creating a new template and sidebar.
First find your sidebar.php file and make a copy of it.
Name the sidebar using wordpress naming convention eg: sidebar-secondary.php.
Make changes in sidebar-secondary.php as per your need.
Make a new template and use your sidebar as <?php get_sidebar(‘secondary’); ?>
EDIT
Assuming that you want one sidebar for homepage and separate for all others you can do the following.
Create sidebar-secondary.php as mentioned above.
The main template is usually index.php. This will usually contain the sidebar for your homepage. You will find some code like <?php get_sidebar() ?>.
If you want secondary sidebar on say page, open your page template page.php. Find the line get_sidebar() and replace it with get_sidebar('secondary'). Now all of your page will use secondary sidebar. You need to do the same if any of your page is using different template.
To display secondary sidebar in you single post page (the page displayed after user clicks readmore in blog section), open single.php and again find and replace get_sidebar() with get_sidebar('secondary').
You can now style and use your sidebar differently for homepage and other pages.
Note that if you only want different sidebar in homepage and same for rest of the page you can also use conditional in your main template file index.php.
if( is_home() ){
get_sidebar(); //your main sidebar for homepage
} else {
get_sidebar('secondary'); //your sidebar for other pages
}
Templates are definitely the way to go, but your solution should work assuming that your "home" page is your blog page. If you've set the home page to be a static page (in the "Reading" section of the dashboard), you should use the is_front_page() function instead of is_home().
I'd also suggest using alternative syntax and closing the PHP tag before your markup, like this:
<?php if ( is_home() ) : ?>
<div class="row">
<div class="span3">
<div id="search-box"><img id="search_text" src="http://localhost/Dorsa/wp-content/themes/Bootstrap/img/text_findyourhome.png">
</div>
</div>
</div>
<div class="row">
<div class="span3">
<img class="box_shadow" src="http://localhost/Dorsa/wp-content/themes/Bootstrap/img/box-shadow.png" style="padding-left:0;">
</div>
</div>
<div class="row">
<div class="span3"><div id="news" style="margin-top:275px;margin-bottom:200px">News</div></div>
</div>
<?php else: ?>
<!-- sidebar 2 code - didn't write it yet" -->
<?php endif; ?>
How do I remove the date added/admin/no comments section of each one of my posts in my wordpress blog here http://www.kvylfm.com
Edit your template file index.php and look for this snippet:
<div class="post-info clear-block with-thumbs">
when you found it, it would be something like this:
<div class="post-info clear-block with-thumbs">
<p class="author alignleft">Posted by .........</p>
<p class="comments alignright">.........</p>
</div>
Just remove it all.
If you don't know what template it is, on admin panel, look at Appearance » Editor.
You should see list of files on right side of that page. Just find 'Main Index Template' and edit it, look at snippet above then remove it.