This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'numberposts' = '4', | |
'category_name' = 'slider' | |
); | |
$slider_posts = get_posts( $args ); | |
if ( $slider_posts ) { | |
foreach ( $slider_posts as $post ) : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
// Define the arguments for the new query | |
); | |
$myQuery = new WP_Query( $args ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title']; ?> | |
<div class="row"> | |
<div class="col-lg-6"><?php | |
foreach( $cat_col_one as $cat_one ) { | |
echo $cat_one; | |
} ?> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach( $categories as $category ) { | |
$cat_count ++; | |
$category_link = sprintf( | |
'<li class="list-unstyled"><a href="%1$s" alt="%2$s">%3$s</a></li>', | |
esc_url( get_category_link( $category->term_id ) ), | |
esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ), | |
esc_html( $category->name ) | |
); | |
if ($cat_count % 2 != 0 ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$title = apply_filters( 'widget_title', $instance[ 'title' ] ); | |
$categories = get_categories( array( | |
'orderby' => 'name', | |
'order' => 'ASC' | |
) ); | |
$cat_count = 0; | |
$cat_col_one = []; | |
$cat_col_two = []; | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function widget( $args, $instance ) { | |
// All widget output will go here | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function jpen_register_example_widget() { | |
register_widget( 'jpen_Example_Widget' ); | |
} | |
add_action( 'widgets_init', 'jpen_register_example_widget' ); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function update( $new_instance, $old_instance ) { | |
$instance = $old_instance; | |
$instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] ); | |
return $instance; | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function form( $instance ) { | |
$title = ! empty( $instance['title'] ) ? $instance['title'] : ''; ?> | |
<p> | |
<label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label> | |
<input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>" /> | |
</p><?php | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function widget( $args, $instance ) { | |
$title = apply_filters( 'widget_title', $instance[ 'title' ] ); | |
$blog_title = get_bloginfo( 'name' ); | |
$tagline = get_bloginfo( 'description' ); | |
echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title']; ?> | |
<p><strong>Site Name:</strong> <?php echo $blog_title ?></p> |