Skip to content

Instantly share code, notes, and snippets.

@rochow
Last active October 12, 2020 21:54
Show Gist options
  • Save rochow/c2e7fc3702b615006c7254f341c08414 to your computer and use it in GitHub Desktop.
Save rochow/c2e7fc3702b615006c7254f341c08414 to your computer and use it in GitHub Desktop.
Elementor Widget Content Override #elementor
<?php
class your_elementor_hooks {
use \Essential_Addons_Elementor\Traits\Helper;
function __construct() {
add_action( 'elementor/widget/render_content', array( $this, 'roxx_carousel_render' ), 10, 2 );
}
public function roxx_carousel_render( $content, $widget ) {
if ( 'eael-post-carousel' === $widget->get_name() ) {
$settings = $widget->get_settings();
$args = $this->eael_get_query_args($settings);
$query = new \WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$title_link = '';
$title_text = '';
if ($settings['eael_show_title']) {
$title_link .= '<'.$settings['title_tag'].' class="eael-entry-title">';
$title_link .= '<a class="eael-grid-post-link" href="' . get_permalink() . '" title="' . get_the_title() . '">';
if(empty($settings['eael_title_length'])) {
$title_text .= get_the_title();
}else {
$title_text .= implode(" ", array_slice(explode(" ", get_the_title() ), 0, $settings['eael_title_length']));
}
$title_link .= $title_text;
$title_link .= '</a>';
$title_link .= '</'.$settings['title_tag'].'>';
}
if ( isset( $settings['boxx_carousel_link_title'] ) && $settings['boxx_carousel_link_title'] == 'yes' ) {
$content = str_replace( $title_link, $title_text, $content );
}
}
}
wp_reset_postdata();
}
return $content;
}
}
new your_elementor_hooks();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment