This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
I am trying to hide a sidebar widget in my wordpress theme. I've done what a help site suggests in the sidebar.php file. But when I add a new page I get a parsing error that says this on the right side of the page where the sidebar should be:
Parse error: syntax error, unexpected 'endif' (T_ENDIF), expecting end of file in C:\xampp\htdocs\Rustic1\wp-content\themes\restau\sidebar.php on line 18
<?php
/**
* The sidebar containing the main widget area.
*
* #link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* #package Restau
*/
?><div id="sidebar">
<!-- Start widget comment>
<?php
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
return;
}
?>
<aside id="sidebar" class="col-md-4 widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
<?php endif; ?>
<End widget comment -->
</div>
</aside><!-- #sidebar -->
I want the sidebar removed from the entire theme.
You have HTML code between the comment and the next <?php tag. You need to exit PHP mode before the HTML.
<?php
/**
* The sidebar containing the main widget area.
*
* #link https://developer.wordpress.org/themes/basics/template- files/#template-partials
*
* #package Restau
*/
?>
<div id="sidebar">
<!-- Start widget comment
<?php
Related
I've built a custom page template in my twentyseventeen child theme that I know is working fine when I go directly to that page but when I set home page of my site to be a static and pointing to that page nothing displays. It will display any of text I have in the body but it does not seem to run any of the code in the template.
The static home page is here: https://wanderreader.com/
The page running on its own is here: https://wanderreader.com/book-list/#
I based my template on the TwentySeventeen page.php and, like I said, I know the code is working fine when I run the page on its own (i.e. not as a static home page) so I'm really scratching my head as to why it doesn't run any of my code when I set it to the home page.
<?php
/**
* Template Name: TravelBooksHome
*
* Derived from the 'page' template for displaying all pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site may use a
* different template.
*
* #link https://codex.wordpress.org/Template_Hierarchy
*
* #package WordPress
* #subpackage Twenty_Seventeen
* #since 1.0
* #version 1.0
*/
get_header();
//Set the Nonce to avoid any shenanigans with the ajax calls
$ajax_nonce = wp_create_nonce( "<removed for posting>" );
?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<div id="MessageArea">
</div>
<div id="SelectedCategory">
Home
<br>
</div>
<hr>
<div id="FilterCategories">
<?php
$categories = get_categories( array(
'orderby' => 'name',
'show_count' => true,
'echo' => false,
'title_li' => '',
'depth' => '1',
'use_desc_for_title' => false,
'parent' => 0
) );
foreach ( $categories as $category ) {
printf( '%2$s<br />',
"categorySubmit('".$ajax_nonce."', ". $category->term_id .")",
esc_html( $category->name )
);
}
?>
</div>
<hr>
<div id="BookList">
</div>
<div id="BookCovers">
</div>
</main>
<!-- #main -->
</div>
<!-- #primary -->
</div>
<!-- .wrap -->
<?php get_footer();
You may want to take a look at this document: https://codex.wordpress.org/Creating_a_Static_Front_Page
On the site front page, WordPress will always use the front-page.php
template file, if it exists. If front-page.php does not exist,
WordPress will determine which template file to use, depending on the
user configuration of 'Settings > Reading ->Front page displays', as
follows:
A static page: WordPress uses the Static Page template hierarchy:
Custom Page Template, page-{id}.php, page-{slug}.php, page.php,
index.php
Your latest posts: WordPress uses the Blog Posts Index
template hierarchy: home.php, index.php
I think in your case you just need to edit or create front-page.php instead of page.php.
I created a template page on WordPress Admin and just added a h2 heading which does not appear with associated link for the page but it's working if admin logged in wordpress login. I also made the page public on page setting but still the problem is not remove page data shown only to admin. I have searched many forums but didn't find any solution.
<?php
/*
Template Name: Contact Us
*/
get_header(); ?>
<div class="contact-box1">
<h2 >
<br><br>
YOUR ENQUIRY
</h2>
<?php get_footer(); ?>
its working fine in here its not problem with the templating i guess you have not selected the template name right side of the dashboard and only put one contact us to the page as http://amplifiedantennas.com.au/contact-us doesnt have anything assigned over there
how to create template in WordPress?
<?php
/**
Template Name: Contact Us
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site may use a
* different template.
*
* #link https://codex.wordpress.org/Template_Hierarchy
*
* #package WordPress
* #subpackage Amplified_Antennas
* #since 1.0
* #version 1.0
*/
get_header();
?>
<?php
while ( have_posts() ) : the_post();
?>
<div class="contact-box1">
<h2>Contact ENQUIRY</h2>
</div>
<?php
endwhile; // End of the loop.
?>
<?php
get_footer(); ?>
EDITED (I included the full code now):
It's not enough to include the header and the footer, you also need to include the loop in order to fetch the content which was for that particular page in the text editor (in the backend), where you should add/create your content.
So after creating that template, you need to create a "new page" in the backend, selecting that page template in the right sidebar.
In my example below, you would write your header into the title field in the backend, then it would be displayed as an h2 in the real page. And the whole content (inluding that title h2) is wrapped in the .contact-box1 DIV, as you had it in your original code.
example:
<?php
/*
* Template Name: Contact Us
* #package WordPress
* #subpackage Amplified_Antennas
*/
get_header(); ?>
<div class="contact-box1">
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
} // end while
} // end if
?>
</div>
<?php get_footer(); ?>
P.S.: In your posted code, you are not closing this DIV tag: <div class="contact-box1">
I want to make the header of this WordPress page taller. I found advice here that I should use the following code in the homepage template CSS file:
.full-container {
min-height: 390px;
}
The CSS file looks like this:
<?php
/**
* The template for displaying the home page panel. Requires SiteOrigin page builder plugin.
*
* Template Name: Page Builder Home
*
* #package vantage
* #since vantage 1.0
* #see http://siteorigin.com/page-builder/
* #license GPL 2.0
*/
get_header();
?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<div class="entry-content">
<?php
if ( is_page() ) {
the_post();
the_content();
}
else if( function_exists('siteorigin_panels_render') ) echo siteorigin_panels_render('home');
else echo siteorigin_panels_lite_home_render();
?>
</div>
</div><!-- #content .site-content -->
</div><!-- #primary .content-area -->
Where must I put the suggested code in?
In a Child Theme or wp-content/themes/vantage/style.css
The code you showed there as the CSS style is not the style at all, thats a costum page template named "Page Builder Home".
You should open style.css which is found directly on the theme folder. At the very end of style.css add the lines of css:
.full-container {
min-height: 390px;
}
If you dont know how to difference css files from php/html files then you definitely are in the wrong business and you should let the work be done by the pro-s.
having said that, hope my "solution" works for you.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
This
is my website I don't know for what reason my sidebar is not showing on the aside and it has gone down. Please anyone help me to fix this issue.
index.php
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* #link https://codex.wordpress.org/Template_Hierarchy
*
* #package Trevelle
*/
get_header(); ?>
<div class="background">
<div class="container padding-top">
<div class="row" id="primary">
<main id="content" class="col-sm-8">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', get_post_format() );
?>
<?php endwhile; ?>
<?php the_posts_navigation(); ?>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; ?>
</main>
<aside class="col-sm-4 lead text">
<?php get_sidebar(); ?>
</aside>
</div>
</div>
</div>
<?php get_footer(); ?>
and here is CSS because its lengthy http://jsfiddle.net/go75571m/
EDITED, ALL NEW ANSWER:
Your theme's CSS contains one setting that breaks the underlying bootstrap CSS.
Locate the following file and open it:
"/trevelle/wp-content/themes/trevelle/style.css"
On lines #2492 - 2497 of that file you find the following rule:
main {
padding:25px;
margin:10px 5px;
color:black;
line-height:30px;
}
In there, change
margin to 10px 0;
That should do the trick. I don't know if that's a little error in the theme or if the wrong behaviour is also caused by something else, but right now, this will fix it.
Those 5px margin left and right of the main element were just a little bit too much: 66, 6667% width (main) plus 33,3333% width (aside) = 100% PLUS those 10px just won't fit into the surrounding container...
I am building a website in wordpress, with the twentythirteen theme. And I want to get rid of the words "this is a blog... (the search bar)... recent posts... recent comments and so forth." But the only page that has any coding for the footer is the footer.php. Here is the coding for the footer.php. Is there anything I am like missing here? Because I am not seeing anything that I can change without the whole footer being removed in general. I am really stuck, can someone out there who can give me some clarity?
<?php
/**
* The template for displaying the footer.
*
* Contains footer content and the closing of the
* #main and #page div elements.
*
* #package WordPress
* #subpackage Twenty_Thirteen
* #since Twenty Thirteen 1.0
*/
?>
</div><!-- #main -->
<footer id="colophon" class="site-footer" role="contentinfo">
<?php get_sidebar( 'main' ); ?>
<div class="site-info">
<?php do_action( 'twentythirteen_credits' ); ?>
<?php printf( __( 'Proudly powered by %s', 'twentythirteen' ), 'WordPress' ); ?>
</div><!-- .site-info -->
</footer><!-- #colophon -->
</div><!-- #page -->
<?php wp_footer(); ?>
</body>
</html>
there are two parts/components in your footer.
A module displayed
credits to WordPress.
if you want to remove side bar remove the code
<?php get_sidebar( 'main' ); ?>
if you want to remove the credits then remove the following code:
<?php do_action( 'twentythirteen_credits' ); ?>
<?php printf( __( 'Proudly powered by %s', 'twentythirteen' ), 'WordPress' ); ?>
else, remove both of them and you will get a clear footer.
I think what you're trying to get rid of are the default widgets. If that's the case, go to Appearance > Widgets, and drag and drop everything you want to remove off of the 'Main Widget Area' drop-down.
"this is a blog... (the search bar)... recent posts... recent comments This is comes from widget. If you don't want this you need to remove those widget.