When I add pictures in an article on wordpress, wordpress automatically add classes to the pictures.
eg :
I simply want to desactivate those added classes, of which I do not see the point and actually annoys me when I want to center a group of pictures.
How can I do so?
I've read about the following filter :
add_filter( 'get_image_tag_class', '__return_empty_string' );
But given that the pictures classes seems dynamical (picture id?), how can I do so? And... where should I do that fork?
Any other method to clean that code?
Thanks !
Solved as previously mentionned in the answers, thanks !
Related
I just started with Wordpress and I published a website a few weeks ago. Today I wanted to edit the homepage, but I get the following error:
Sorry, the content area was not found in your page. You must call the_content function in the current template, in order for Elementor to work on this page.
I haven't edited my homepage and it worked perfectly a couple of weeks ago. Is there someone that can help me fix this issue?
If you are using any shortcode on your page and you are fetching post on that page and looping through the post in a while loop. Please add this after the loop ends. No sure why but this always cause issue for me.
wp_reset_postdata();
Code will look like this:
$posts= new WP_Query($args);
while ($posts->have_posts() ) : $posts->the_post();
.....
.....
.....
endwhile;
wp_reset_postdata();
It doesn't matter it's a shortcode or what if we are doing something like above make sure to add wp_reset_postdata();
This is one of the issues that I usually face. There can be other reasons too.
Probably you've edited the page template from Templates -> Theme Builder -> Single. Anyway, even if you don't, you can fix it that way: Go to Templates -> Theme Builder -> Single -> Add New, then select page and create a template for all single pages (make sure that you drag the page content widget in the template). This should overwrite your theme single page template (which misses the content function).
Just make sure your 'Home Page' and 'Posts Page' are different, otherwise you get your page mixed up and this error occurs.. Worked for me!
You can verify this setting in Appearance>Customize>Homepage Settings :)
The Answer to this error is to check the structure of your permalinks. Try to save your permalinks one more time. Also, try to change the permalink structure to “Plain”. Some servers do not allow to write to the .htaccess file and as a matter of fact, you cannot always modify your permalink structure and edit with Elementor.
I found myself in the same place yesterday and freaked for a moment and did some research to find out why I was receiving the error and came across this page. Believe for me it occurred due to the situation Ed Jones posted about above, I had inadvertently edited the post template. But a fast and easy fix was to go back to an earlier revision of the page in my history. That solved my problem quickly.
Add the_content() at the end of your templates
I am trying to add a button to my WordPress template. Basically, I have the post and then there is the Related Posts Thumbnails widget that appears. I want the button to go between the text of the post and the related posts thumbnail widget. The code in my 'Single Post' that contains all of this is as follows:
<div class="post-content">
<?php the_content(__('<em><strong>More:</strong> Read the rest of this entry...</em>', 'life-is-simple')); ?>
</div>
I know the Related Posts Thumbnails plugin falls within this code because it's at that place when I 'Inspect Element' on Google Chrome. I can't find how to edit the order of things within that div though. Any help would be greatly appreciated, thanks!
EDIT
Clarification: I am using the Life Is Simple WordPress theme although it has been custom editing quite a bit (mostly on the CSS side of things though).
That plugin is probably appending the output to the_content with a filter .
That means , that the output is being added to the_content automatically. it is a common behaviour.
You need to look at the plugin´s admin interface to see if you can have an alternative way (I believe there is ) which is using a template tag. in that case, you should put the template tag after the div where the the_content() is .
EDIT I :
After a small dig, - in fact there is - you need to put
<?php get_related_posts_thumbnails(); ?>
Then the plugin should know by itself not to append to the_content.
For parameter passing, or if something is not working, go read their APi or help files.
You'll probably need to edit single.php or archive.php in your theme. If nothing is occuring there that looks familiar, it's probably using a loop. In which case you might find what you are looking for either in loop.php, loop-single.php, or loop-archive.php depending on what type of page you are on and how the theme was constructed. Add your button near where you find Read the rest of this entry...
With more information (such as what theme you are using), one might be able to help more as well.
I am trying to add http:// in the post link dialog box if there is not already added. I tried with filter
add_filter('pre_link_url', 'add_http_link_url');
It didn't work. Does anybody know how to do that ?
Doesn't Wordpress automatically add the "http://" there by default?
Maybe this plugin would help?
wordpress.org/extend/plugins/auto-hyperlink-urls/
EDIT
found this on http://betterwp.net/wordpress-tips/make-links-clickable/
a function named make_clickable() that can be found in wp-includes/formatting.php.
make_clickable() filters the comment_text hook with this:
add_filter( 'comment_text', 'make_clickable', 9 );
Since it is that simple, let’s try adding the same filter to our post contents and see if it works
add_filter( 'the_content', 'make_clickable', 12 );
The priority of 12 as used above simply tells WordPress to make links clickable for post contents after shortcodes are parsed (which is at priority 11). If you don’t like such behaviour, just change 12 to any number you want. You should take a look at wp-includes/default-filters.php to choose an appropriate priority for make_clickable().
Being that awesome, however, make_clickable() has a limitation, which you can clearly see in this clickable link: http://codex.wordpress.org/Function_Reference/make_clic ... _clickable.
See the full stop punctuation mark also included in the link, thus making it broken? To avoid such behaviour you must always have one space plus another character after a plain link, or in other words, never put a plain link like that at the end of a paragraph. In case you must, just make the link clickable the normal way .
Of course if you don’t like your visitors to be able to post links that way you can easily remove the filter using:
remove_filter('comment_text', 'make_clickable', 9);
hope this helps, sorry i had to remove the first link as i can only post 2 links till i get my rep up :)
I am working in worpress front page.
I want to add a plugin to the page at a specific location manually but adding the code to the page myself.
I basically want to include a plugin in a certain page on a certain location. So I'm create a div...
<div id="plugin-holder">
**Plugin-will-appear-here-with-this-code**
</div>
Don't anyone know how this is done please?
Thanks
If you're wanting a plugin to appear somewhere, you'll be looking for "shortcode" functionality.
This is actually surprisingly easy to code, check out the examples in the Codex under Shortcode API - ie:
function bartag_func( $atts ) {
// ... do more things here ...
return "text to replace shortcode";
}
add_shortcode( 'bartag', 'bartag_func' );
Once you've called these functions you can use [bartag] in code and it will run your function and replace the shortcode with the generated text your function returns.
If you're adding shortcode functionality to your site, it generally makes most sense to code a really simple plugin and put it in that. The reason why this works best is that, over time, it's really easy to forget and upgrade a theme by mistake (or even change to a new theme) and thus break your site by losing your custom code in your former functions.php. Surprisingly, this is pretty easy to achieve and only requires some specially formatted comments at the top of your plugin file and a little common sense in coding - there are many tutorials and "how to"s around!
Here's a useful shortcode tutorial: http://www.reallyeffective.co.uk/archives/2009/06/22/how-to-code-your-own-wordpress-shortcode-plugin-tutorial-part-1/
You should add the relevant plugin code to functions.php.
I suspect you'll want to use some conditional tags, like is_home() to pinpoint your location. But maybe not, depending on what you are trying to do,
Also, if you're trying to to insert from a pre-existing plug-in, make sure you remove the register_activation_hook or activate_pluginname action.
If your plugin supports a sidebar widget you can simply "widgitize" the div tag that you wish to insert the plugin into.. Google the term and you are gonna find many resources.
The size of my posts’ featured images is 700x400 or more, and in order to display them center-cropped to 300x400 I use :
the_post_thumbnail(array(300,400));
However this code displays everything except a 300x400 image. Anybody could tell me how to achieve what I want ?
As the function manual says:-
PLEASE NOTE: The crop does not work in
Wp 3.0+. All that is needed for WP
3.0+ is the call for the thumbnail to post. Then proceed to media in the
dashboard and set your thumbnail to
crop to the size you wish to use.
http://codex.wordpress.org/Function_Reference/the_post_thumbnail
See here: http://gavinsmith.me/2010/10/multiple-post-thumbnail-featured-image-sizes-in-wordpress/
You can dig a bit further than using only the_post_thumbnail and actually create your own image sizes. Then, using the_post_thumbnail, you can call the image - but the version you have created using add_image_size, as described on that page. Let me know if I lost you there.
try out this
<?php echo the_post_thumbnail(array(32,32)); ?>
You can Increase size on desire