Created
September 22, 2021 19:14
-
-
Save TeamBug99/d6e2c6a88953904156caac24bc756b7e to your computer and use it in GitHub Desktop.
WP Basic functions
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
| // loop | |
| <?php while(have_posts()): the_post(); ?> | |
| <h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> | |
| <?php endwhile; ?> | |
| //Thumbnail | |
| <?php | |
| if(has_post_thumbnail()){ | |
| the_post_thumbnail("large", array('class' => 'img-fluid')); | |
| } | |
| ?> | |
| // Pagination | |
| <?php | |
| the_posts_pagination( array( | |
| "screen_reader_text" => " ", | |
| "prev_text" => "New Post", | |
| "next_text" => "Old Post" | |
| )); | |
| ?> | |
| // Tag list | |
| <?php echo get_the_tag_list("<ul class=\"list-unstyled\"><li>","</li><li>","</li></ul>"); ?> | |
| // Comments template | |
| <?php if(comments_open()): ?> | |
| <div class="comments_form"> | |
| <?php comments_template(); ?> | |
| </div> | |
| <?php endif; ?> | |
| //Widget | |
| function alpha_sidebar(){ | |
| register_sidebar( array( | |
| 'name' => __( 'Single Post Sidebar', 'alpha' ), | |
| 'id' => 'sidebar-1', | |
| 'description' => __( 'Right Sidebar', 'alpha' ), | |
| 'before_widget' => '<section id="%1$s" class="widget %2$s">', | |
| 'after_widget' => '</section>', | |
| 'before_title' => '<h2 class="widget-title">', | |
| 'after_title' => '</h2>', | |
| ) ); | |
| } | |
| add_action("widgets_init", "alpha_sidebar"); | |
| //Widget call | |
| <?php | |
| if(is_active_sidebar("sidebar-1")){ | |
| dynamic_sidebar( "sidebar-1" ); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment