Useful function for elementor in wordpress

30. July 2017

Notice: Uninitialized string offset: 0 in /usr/www/users/franssr/fransstudio.de/wp-content/themes/fransstudio2017/functions.php on line 25

Sometime you want to show the title of your post or page, or maybe use a wrapper for max-width. Well, using Elementor is nice and easy, but you usually need to remove wrapper classes because Elementor can/want to control if a content full width or not. Or maybe you want to hide title if Elementor is active, since you want to be able to edit the title in Elementor.

Sure you can use Elementor built in “hide title” – but the problem comes if you have a blog like posts index page.

I snooped around in the database and found that Elementor uses a post meta in WordPress to mark a page/post is an elementor post and I wrote a piece of code that use the post meta to use in the template.

Look at this example:

<?php $is_elementor = count(get_post_meta($post->ID, '_elementor_edit_mode'));?>
<?php if (!$is_elementor): ?>
<h3><?php the_title(); ?></h3>
<?php endif; ?>

If it need to be really sure that the ID is coming from the post, one could use $post = get_post(); to assign it.

Hope this helps.