Custom Sidebar to Use in First Page Above Featured Content as Announcement
-
Firstly before we start you can visit to my blog.
These are the steps that I applied:
Step 1:
I created New Sidebars from Theme Options. I named the Sidebar ID: sidebar-announcementStep 2:
I created new php file in Child Theme, which is the name sidebar-announcement.phpThe coding inside php file are:
<?php dynamic_sidebar('sidebar-announcement'); ?>
Step 3:
I put some coding into index.php, because I want the announcement appear above featured content.The coding inside php file are:
<?php get_header(); ?> <section class="content"> <?php get_template_part('inc/page-title'); ?> <div class="pad group"> <?php include ('sidebar-announcement.php'); ?> <?php get_template_part('inc/featured'); ?> <?php if ( have_posts() ) : ?> <?php if ( ot_get_option('blog-standard') == 'on' ): ?> <?php while ( have_posts() ): the_post(); ?> <?php get_template_part('content-standard'); ?> <?php endwhile; ?> <?php else: ?> <div class="post-list group"> <?php $i = 1; echo '<div class="post-row">'; while ( have_posts() ): the_post(); ?> <?php get_template_part('content'); ?> <?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?> </div><!--/.post-list--> <?php endif; ?> <?php get_template_part('inc/pagination'); ?> <?php endif; ?> </div><!--/.pad--> </section><!--/.content--> <?php get_sidebar(); ?> <?php get_footer(); ?>
Step 4:
I can used the sidebar-announcement in widget area and put some text for first announcement. That’s all.Question:
If you guys get through 2nd page, you still be able to see the announcement. How to make the announcement ONLY CAN VIEW on 1st page. What is the code that I need to put inside php file?
- The topic ‘Custom Sidebar to Use in First Page Above Featured Content as Announcement’ is closed to new replies.