I'm trying to remove the sidebars from a WordPress site;
should be a pretty straight-forward action to do, but I have a problem:
I've commented every get_sidebar() I've found in my theme PHP page (including index.php, page.php etc) but seem that have no effect on the site.
Here is an example from my index.php:
<?php get_header(); ?>
<div id="page-wrapper" class="container">
<div class="row">
<div id="page-content" class="col-sm-7 col-md-8">
<?php if ( have_posts() ) : ?>
<?php get_template_part( 'templates/page-title' ); ?>
<?php $blog_layout = vw_get_option( 'blog_layout' ); ?>
<?php if ( 'classic' == $blog_layout ) : ?>
<div class="row archive-posts post-box-list">
<?php while ( have_posts() ) : the_post(); ?>
<div class="col-sm-12 post-box-wrapper">
<?php get_template_part( 'templates/post-box/classic', get_post_format() ); ?>
</div>
<?php endwhile; ?>
</div>
<?php else: ?>
<div class="row archive-posts vw-isotope post-box-list">
<?php while (have_posts()) : the_post(); ?>
<div class="col-sm-6 post-box-wrapper">
<?php get_template_part( 'templates/post-box/large-thumbnail', get_post_format() ); ?>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php get_template_part( 'templates/pagination' ); ?>
<?php comments_template(); ?>
<?php else : ?>
<h2><?php _e( 'Sorry, no posts were found', 'envirra' ) ?></h2>
<?php endif; ?>
</div>
<!--aside id="page-sidebar" class="sidebar-wrapper col-sm-5 col-md-4">
<?php // get_sidebar(); ?>
</aside-->
</div>
</div>
<?php get_footer(); ?>
in the example above you can see both html / PHP comment, but I've also tried with only HTML comment / only PHP comment.
may notice that i'm using a Child theme, but I've found the get_sidebar() only in the father theme.
I'm probably missing something stupid, should i remove the entire line? i'm not an WordPress expert so i'd like to do the less intrusive modification.
Thanks!
Usually there is an option within the most of WP themes to turn off the sidebar(s), also theme authors care to give you a simple checkbox for that in the single Page, Post, or even Category template, but sometimes there is no easy way out.
I suggest you check this guide back from 2017 and a bit more fresh one from 2019 here, most likely you will find your way without additional plugin in the first reference.
Related
I am new to wordpress. I have a problem with pagination when I click to the next post it shows "not found". I installed the plugin wp pagenavi, and I put code in my blog post <?php wp_pagenavi(); ?>. It shows the pagination, but I have a problem with the link to the next post. Example when I click to the next post — http://westecmedia.com/events/page/2/ — it shows:
Something went Wrong!
404
-->
You can see at: http://westecmedia.com/events/
And this is my code in event-page.php:
<?php
/*
* Template Name: Page - Events Page
*/
?>
<?php get_header(); ?>
<div id="content-events">
<div id="head-event"><h3>EVENTS</h3></div>
<div id="main-event">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else: endif; ?>
<?php query_posts('category_name='.get_the_title().'&post_status=publish,future');?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div id="part-event">
<div id="entry-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<div id="event-dess">
<h2><?php the_title(); ?></h2>
<p>
<?php
$content = get_the_content();
$content = strip_tags($content);
echo substr($content, 0, 300);
?>
</p>
<div id="read-more">Read More</div>
</div>
</div>
<div id="line-bottom"></div>
<?php endwhile; else: endif; ?>
<?php wp_pagenavi(); ?>
</div>
</div>
<?php get_footer(); ?>
Who can help me please?
https://codex.wordpress.org/Function_Reference/paginate_links
Please try using this instead of plugin. Also add this code before the if loop ends.
Loop on my front page not showing results.
<?php define('WP_USE_THEMES', false); get_header(); ?>
<div class="site-row clear">
<div class="center">
<?php get_sidebar(); ?>
<div class="showcase">
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
echo '1';
endwhile;
endif;
?>
</div>
</div>
</div>
<?php get_footer(); ?>
It's show '1', but i have lot posts. People, tell me please what i do wrong?
UPD.
This code is in front-page.php . On local server all posts showing, but on hosting didn't show. Instead Echo '1' i use the_content(). echo '1' just for debugging.
I am trying to only load the 4 latest posts on my page and I have found a line of code that should work. The problem is that I don't know where to put it.
<?php query_posts('posts_per_page=20'); ?>
This is what I found when I was searching for a solution (although I don't know if this will also work for showing only the 4 newest posts. As you can see I already have 'catname=projecten' on that line and I have no idea how to combine the two.
<?php
query_posts('catname=projecten');
while (have_posts()) : the_post();?>
<div class="col-md-3">
<div class="newsfeed center">
<h1><?php echo get_the_title( $ID ); ?> </h1>
<p>
<?php the_content(); ?>
</p>
</div>
</div>
<?php endwhile;
?>
I hope someone can help me out!
I'd like to answer it, because there are few things need to be corrected. This should do it, and notes below.
<?php
query_posts('category_name=projecten&posts_per_page=4');
while (have_posts()) : the_post(); ?>
<div class="col-md-3">
<div class="newsfeed center">
<h2><?php echo get_the_title(); ?> </h2>
<?php the_content(); ?>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
A few notes:
It's category_name, not catname.
You should not use <h1> for each title, for a better accessibility use <h2> or <h3> etc.
get_the_title( $ID ); the $ID seems not necessary to be there.
Don't wrap the_content(); with <p> it's rich content already, use <div> if you need.
Don't forget to reset the query afterwards.
http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
http://codex.wordpress.org/Function_Reference/query_posts
http://codex.wordpress.org/Class_Reference/WP_Query
I have a signifiantly big problem up there.
I'm trying to design my search restult page on WordPress, but if it comes that the search find a page with the keyword I just entered, it display the entire page instead of the title();
My code
<?php
/**
* The template for displaying search results pages.
*
* #package miller
*/
get_header(); ?>
<section id="primary" class="content-area">
<main id="int_top_main" class="internal blue_top" style="min-height:80px;">
<div class="wrapper">
<h2 class="page_title uppercase"><span class="parent_page">Search results</h2>
<div id="infinite_blue_top_bar"></div>
</div>
</main><!-- #main -->
<div id="int_content_main" class="internal">
<div class="wrapper physician_headline">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php else : ?>
<h2><?php _e( 'Nothing Found', 'miller' ); ?></h2>
<div class="page-content">
<?php if ( is_search() ) : ?>
<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'miller' ); ?></p>
<?php else : ?>
<p><?php _e( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', 'miller' ); ?></p>
<?php endif; ?>
</div><!-- .page-content -->
<?php endif; ?>
</div>
</div>
</section><!-- #primary -->
<?php get_footer(); ?>
If it finds nothing, it will go into the else: but if it do finds something they display all the pages (fullpage) of what it finds out there.
It should only display the_title(); but no..
Even if I completly destruct the search.php file it stills automaticly goes to the "suggested" page.
First time I am getting this kind of thing and I do not know how to solve it :(
It's calling for the post before the title, which is why it pulls for the full post.
Try:
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_title(); ?>
<?php endwhile; ?>
<?php else : ?>
I have been trying to use several conditional statements using is_home/is_front_page or is_single and they are not working in my theme. Below is an example on such code:
<?php if(is_front_page() || is_home() ) : ?>
<?php if(function_exists('show_flexslider_rotator'))
echo show_flexslider_rotator('homepage_fexslider' ); ?>
This loads my Flexslider, but when I go to page 2, the slider remains on the page.
I have used these statements successfully in other themes.
Do I need to add support for this feature in my functions.php?
How can I troubleshoot this?
My home.php code is as follows:
<?php get_header(); ?>
<?php if(is_front_page() || is_home() ) : ?>
<?php if(function_exists('show_flexslider_rotator')) echo show_flexslider_rotator( 'homepage' ); ?>
<?php endif; ?>
<div class="row below-banner">
<div id="site-content" class="span8">
<div class="row">
<div class="span8">
<div class="widget-header">
<h2>What's new</h2>
</div>
</div>
</div>
<div class="row">
<div class="posts span8">
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') :1; query_posts('cat=-35&paged=' . $paged);?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'entry' ); ?>
<?php endwhile; ?>
<?php wp_pagenavi(); ?>
<?php else : ?>
<h2>No Posts Found</h2>
<?php endif; wp_reset_query(); ?>
</div>
</div>
<?php get_footer(); ?>
We would need more info/code in order to give a definitive answer, but my best guess is that you need to add a wp_reset_query() somewhere.
A quick test: add wp_reset_query() immediately before the conditional statements and see if that resolves the issue. If so, then you need to find the offending query and make sure it is reset at the appropriate time.
The issue with wordpress conditionals like is_single is that they don't work outside a functions in functions.php
So the solution is to place the conditional within the function and call that function using add_action probably.
The code here is_single not working in functions.php explained how it won't work outside the function and how should it be instead