i want to make a page that is NOT the homepage a bit different from the others. I want that in the "middle" of the page there is no simple text or images, but rather a "complex" structure made of an array of divs with hidden sections that can be shown or not, so not the average wordpress content. I kinda made it in a simple local HTML page using bootstrap as framework, now i have to incorporate this into the wordpress page, but i don't know if wordpress CAN do it, using a closed source theme.
What i should do to achieve this?
At first, need to enqueue the bootstrap file into your theme. Then create a page template where you implement design it. Goto your WordPress Theme Directory edit functions.php and enqueue CSS & JavaScript.
/**
* Proper way to enqueue scripts and styles
*/
function bootstrap_assets() {
wp_enqueue_style( 'bootstrap', 'https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/css/bootstrap.min.css' );
wp_enqueue_script('jquery');
wp_enqueue_script( 'bootstrap', 'https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/js/bootstrap.min.js', array('jquery'), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'bootstrap_assets' );
After enqueue assets then need to create a page template into your theme folder. you can set it's your preferred name. I use this time name of file test.php.
<?php
/**
* Template Name: Test
*
* #package WordPress
* #subpackage Twenty_Fourteen
* #since Twenty Fourteen 1.0
*/
get_header();
?>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Your Custom Title here</h1>
<p>Your custom description here</p>
</div>
</div>
</div>
<?php
get_footer();
Successfully create page template after need to create a page then select your template & publish it.
If you want to push content via WordPress editor then use the below template.
<?php
/**
* Template Name: Test
*
* #package WordPress
* #subpackage Twenty_Fourteen
* #since Twenty Fourteen 1.0
*/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while (have_posts()) : the_post();
the_content();
// End of the loop.
endwhile;
?>
</main><!-- .site-main -->
<?php get_sidebar('content-bottom'); ?>
</div><!-- .content-area -->
<?php
get_footer();
Related
I installed Advanced Custom Fields and created a field group called "Apps", that shows up whenever a post is made under the apps category. IN that group is a "description" field. The field shows up without fail, or doesn't when the conditions aren't met, while making the post. However, after modifying the singular.php file in the twentytwenty theme to show the field on the front end, nothing changes. I am using the the_field function, like so:
contents of singular.php
<?php
/**
* The template for displaying single posts and pages.
*
* #link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* #package WordPress
* #subpackage Twenty_Twenty
* #since Twenty Twenty 1.0
*/
get_header();
?>
<main id="site-content" role="main">
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
get_template_part( 'template-parts/content', get_post_type() );
the_field('Apps_description');
}
}
?>
</main><!-- #site-content -->
<?php get_template_part( 'template-parts/footer-menus-widgets' ); ?>
<?php get_footer(); ?>
I tried putting the the_field function as individual php outside the while loop as well; same result.
Is there something I'm missing? This appears to be what was laid out in the ACF function reference.
Thanks!
I have created a custom page-template with child theme of Official WordPress twenty-seventeen theme.
However i have problem on mobile devices, the pages are not mobile friendly and i get the popup from chrome to make the page mobile friendly and indeed the content is not readable at all on mobile devices.
I am trying make it friendly using W3.css framework, how can i do the content mobile friendly with w3.css or just some css or any other library? Below is the code of the template. Here it is the template-page i use and is not mobile friendly.
<?php
/**
* Template Name: More info template
*
* Description: A custom template for displaying a fullwidth layout with no sidebar.
*
* #package Twenty Seventeen Child
*/
?>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<div style="padding:5px;" class="wrap">
<div id="primary" class="content-area">
<main id="main info-template" class="site-main w3-padding" role="main">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/page/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .wrap -->
Either create another header and footer specifically for this template so header-new.php and call with:
get_header('new');
or else copy the content of the header.php and footer.php into the top and bottom of your template and remove the html elements that you don't need.
The following tags should NOT be ignored in a template:
<head> <html> wp_head(); and wp_footer();
I am creating custom search feature in a theme. I have created a form on the homepage and with action set to a custom php search page. Form looks like this somewhat. I AM GETTING Class WP_Query not found Error. How to make it work?
The woo-search.php looks like this. I am using this as a template file. forms action attribute links to the page which has this template applied
<?php
/**
* The 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 will use a
* different template.
* Template Name: Search Page
* #package WordPress
* #subpackage Twenty_Twelve
* #since Twenty Twelve 1.0
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php
global $wp_query;
global $wpdb;
if (isset($_POST['submit'])) {
// echo "Submitted <br>";
$product_kinds = $_POST['product-kinds'];
echo $product_kinds;
$the_query = new WP_Query(array('category_name' => '2-wheeler-batteries'));
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
}else{
echo "Get Away";
}
?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
For demonstration purpose the query inside wp_query is static. I want to display the search result just like the shop page looks like, I mean with product image, then title, then price and add to cart button. With above code I will need to fetch all seperately and code it to look like the shop page. How do I fetch Woocommerce layout in this search results. What changes should I make in the while loop.
I created a new WordPress Template named "Footer page". When a new page is created in WordPress and the user selects the template "Footer page" the new page should not appear in the navigation bar.
I did some research and found something called "Exclude Pages from List" that says "Use the exclude parameter to hide certain Pages from the list to be generated by wp_list_pages." but have no idea where I should put it my template file? Or if this is the best way to exclude a template page from the navigation bar?
My code for footer-page.php is as follows:
<?php
/**
* Template Name: Footer page
*
* A custom page template that does not appear in the navigation bar.
*
* The "Template Name:" bit above allows this to be selectable
* from a dropdown menu on the edit page screen.
*
* #package WordPress
* #subpackage Twenty_Ten
* #since Twenty Ten 1.0
*/
get_header(); ?>
<div id="container" class="one-column">
<div id="content" role="main">
<?php
/* Run the loop to output the page.
* If you want to overload this in a child theme then include a file
* called loop-page.php and that will be used instead.
*/
get_template_part( 'loop', 'page' );
?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_footer(); ?>
You can Try Like this:
if (is_page('1') || is_page('5')) {
// include template "sidebar.php".
get_template_part( 'loop', 'page' );
}
read this
i m working on wordpress with bootstrap theme.i m using a Main left-sidebar on my site.as i put the code into WIDGETS> MainSidebar but now i have a problem that on clicking a link i want to open another page having same as my home page but different sidebar.how can i achieve it??
Here is my Template for bootstrap:Page Template (page.php)
<?php
/** page.php
*
* The 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 will use a
* different template.
*
* #author Konstantin Obenland
* #package The Bootstrap
* #since 1.0.0 - 07.02.2012
*/
get_header(); ?>
<div id="primary" class="span9">
<?php tha_content_before(); ?>
<div id="content" role="main">
<?php tha_content_top();
the_post();
get_template_part( '/partials/content', 'page' );
comments_template();
tha_content_bottom(); ?>
</div><!-- #content -->
<?php tha_content_after(); ?>
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();
/* End of file page.php */
/* Location: ./wp-content/themes/the-bootstrap/page.php */
You must have two different sidebars.
Put sidebar code in a custom template name them you like.
see how to Create custom template link
and use wordpress conditional tags like.
if(is_page( 2 )){ // 2 is page id
get_template_part( 'custom', 'sidebar' ); // (custom-sidebar.php)
}
else{
get_sidebar();
}
conditionnal tags
By this way you can have 2 sidebars on different pages.