Wordpress - get_search_form() on same line as icons - php

I would like to display a few icons on the same line as my search form. It really wants to be on its own line. I originally had it added as a form instead of being called through php which worked but I would like it to be more dynamic as you can see. Is it impossible to do this without adding as a form?
Here is a trimmed down example:
Old way:
<div>
<img src="#">
<img src="#">
<form><input type="text"></form>
<img src="#">
<img src="#">
</div>
New way:
<div>
<img src="#">
<img src="#">
<?php get_search_form(); ?>
<img src="#">
<img src="#">
</div>

You should see searchform.php and check the styles in style.css for this form.

In my searchform.php there is a element.
I simply added display:inline; to the form making:
<form style="display:inline;">
Now everything is displayed on one line.

Related

Image not showing in header when added in div

I have Below code in my header.html
<div class="col-md-3">
<div class="logo">
</div>
</div>
But it's not showing my png image in header, Is the way adding image path in div is wrong?
<img src="http://example.com/themes/default/images/logo.png">
That is how you use an image. You are placing a link to the image.
Also, you are not seeing anything because your <a></a> tags are empty. If you write something between them, you can click on it, to see the image you linked.
Add Image inside the img tag not in a tag
<img src="http://example.com/themes/default/images/logo.png">
You should do is this way. img tag is used to display image.
Good practice is to link the logo to the home page of the website.
<div class="col-md-3"><div class="logo"><img src="http://example.com/themes/default/images/logo.png" alt="Site Name or Logo"/></div></div>
put link or path in img tag source(src) not anchor tag.
<div class="col-md-3">
<div class="logo">
<img src="http://example.com/themes/default/images/logo.png" alt="">
</div>
</div>

How to convert an html content to wordpress

I have the following html code that tried to place in my WordPress page.
html:
<div class="hovereffect">
<img src="<?php echo get_template_directory_uri() ?>phone.jpg" >
<div class="overlay">
<h2>Hover effect 9</h2>
<a class="info" href="#">link here</a>
</div>
</div>
At the moment everything is in the site except the image that does not show.
How can I use this code WordPress in a way that it can display the image?
I think you forget to tell which place it should get the images from. And you are also forgetting a semicolon after the get_template_directory_uri();.
This is an example, but here i'm telling which folder to get the image from:
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/your_image.jpg">
you can do that but it is not a good practice to paste this code as it is in WordPress editor,
upload this image in media and get link of that image
Edit page, select text mode from top right corner of your editor and paste code these i.e
<div class="hovereffect">
<img src="http://example.com/wp-content/uploads/2016/07/img.png" >
<div class="overlay">
<h2>Hover effect 9</h2>
<a class="info" href="#">link here</a>
</div>
</div>
Here is good practice create a template for that page and write there your code.
Image replace with feature image
Heading with page title.
Detail with page content
link with page permalink.
Not enough reputation to leave a comment so I will leave this as an answer instead.
Assuming phone.jpg is at the root of your theme, you're forgetting the / (slash) before phone.jpg.
It should be
<img src="<?php echo get_template_directory_uri(); ?>/phone.jpg" >
PHP won't get parsed inside a page. Just upload the image to the WordPress media library and link to it directly.

Wordpress images don't get displayed

I started to learn Wordpress and I'm making my own theme. Within the design I have some images that are supposed to show up... but they don't.
I was using this code:
<div class="col-xs-4">
<img src="images/html_brand.jpg" class="img-responsive">
</div>
and then I found I should use php to link to my image:
<div class="col-xs-4">
<a href="#">
<img src="<?php bloginfo('stylesheet_directory'); ?>html_brand.jpg"
class="img-responsive">
</a>
</div>
But the problem is, the image still doesn't get displayed. And yes I did upload them to my web server. I have them in the directory of my theme: mythemename/images/html_brand.jpg
If you use bloginfo() to output your theme path, you need to add another /, followed by the remaining path to your image. Based on where you've placed your image, this should work:
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/html_brand.jpg" class="img-responsive">
However, bloginfo() ultimately relies on get_template_directory_uri() to work, so you might as well just use that:
<img src="<?php echo get_template_directory_uri(); ?>/images/html_brand.jpg" class="img-responsive">
Slight Correction:
bloginfo() with the specific argument of stylesheet_directory actually relies on get_stylesheet_directory_uri() to function -- get_template_directory_uri() like I originally said.
https://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/general-template.php#L439

How to correctly use get_template_directory_uri() WordPress function to load an image that is in a subfolder of my theme?

I am pretty new in WordPress and I have the following doubt about how to insert in my homepage an immage that is in a subfolder into my theme directory.
So I have the following situation: Into my custom theme directory I have the following folder that contains a jpg immage: /assets/img/flexslider/flex-1.jpg
Now in my header.php file I have something like this:
<li>
<img src="assets/img/flexslider/flex-1.jpg">
<div class="flex-caption">
<p class="flex-caption-text">
<span>Lorem ipsum</span><br>
<span>sit dolor</span><br>
<span>adipiscing elitur</span>
</p>
</div>
</li>
Obviously, when I load the page, the immage flex-1.jpg is not loaded because there is not the right path (infact using FireBug I obtain that it try to load the assets/img/flexslider/flex-1.jpg immage) so I think that I could use the absolute path but this is pretty orrible !!!
So I am thinking to use the get_template_directory_uri() function provided from WP to do this and I have try to change the previous code in this way:
<li>
<img src=<?php get_template_directory_uri().'/assets/img/flexslider/flex-1.jpg' ?>>
<div class="flex-caption">
<p class="flex-caption-text">
<span>Lorem ipsum</span><br>
<span>sit dolor</span><br>
<span>adipiscing elitur</span>
</p>
</div>
But don't work and using FireBug I can see that load nothing, infact in my brower source code I have:
<img src="">
Why don't work? What am I missing?
Tnx
Andrea
I hope it will work:
<img src="<?php echo get_template_directory_uri(); ?>/assets/img/flexslider/flex-1.jpg" />
If your assets folder inside theme.
please try :
<img src="<?php print(get_template_directory_uri()); ?>/assets/img/flexslider/flex-1.jpg" />
just check for slash, if double before "assests", remove static one.
You can also use:
<img src="<?php bloginfo('template_url'); ?>/images/yourimage.jpg">

ckeditor auto content change

I am using ckeditor to insert some html structure into db. I firstly use code view to paste html structure into editor, after inserting into mysql db, until echo at webpage, the html structure data are still maintained.
However, when the same data is called into the same ckeditor again for updating, the structure is destroyed, and I found the ckeditor has automatically changed html tags to the codes, below is an extract:-
A) html code to be pasted to editor code view for inserting (good)
<a href="#">
<img src="../catalog/view/theme/default/images/services/b1.jpg" alt="" />
<div class="btn-gradient-yellow">Details
<div class="btn-arrow"></div>
</div>
<div class="cat-title-bg">
SERVICES
</div>
</a>
B) db data (good)
<a href="#">
<img src="../catalog/view/theme/default/images/services/b1.jpg" alt="" />
<div class="btn-gradient-yellow">Details
<div class="btn-arrow"></div>
</div>
<div class="cat-title-bg">
SERVICES
</div>
</a>
C) webpage data called from db (good)
called by html_entity_decode($record["content"],ENT_COMPAT, 'UTF-8');
<a href="#">
<img src="/catalog/view/theme/default/images/services/b1.jpg" alt="" />
<div class="btn-gradient-yellow">Details
<div class="btn-arrow"></div>
</div>
<div class="cat-title-bg">
SERVICES
</div>
</a>
D) code view in ckeditor, with contents filled from the above data (changed)
called by html_entity_decode($record["content"],ENT_COMPAT, 'UTF-8');
<img alt="" src="../catalog/view/theme/default/images/services/b1.jpg" />
<div class="btn-gradient-yellow">Details
<div class="btn-arrow"> </div>
</div>
<div class="cat-title-bg">SERVICES</div>
How can I ask ckeditor not to add changes to the data?
CKEditor modifies your HTML because it is incorrect. You cannot put block elements inside of <a> unless you use HTML5 which isn't supported by CKEditor yet.
See my answer for related question. Also take a look at this one regarding blocks in <a>.

Categories