Thanks for your quick reply @joyously.
I guess I am a bit confused at how you stated the corrections.. but I will take the advice of someone who is more experienced than I.
Note: I miss-typed the name of the home page.. you were right.. it is called: front-page.php.
Since I am creating the website and content initially for the whole site, I will be creating the new widgets via function.php page. And I will be (instead of the user) be filling in the content of the widgets.. at least first time around. I agree in most cases, the widgets are used in the sidebar, but the one I am trying to add is going be be pulled into my home page. Since the home page is a static page, it is setup to use the font-page.php page as it’s page template.. hence the reason I am calling the widget from that page.
The code I gave you has worked fine for several websites I have created using this same based template. You can see the website I used as a base here: oasisflighttraining.com.au – . If you look at the bottom of that home page (just before the footer), you will see 3 clickable images. They are all in their own widget area.. and they are called there from the front-page.php page. (These 3 widgets are actually the ones I am trying to remove for the new website.. at the same time trying to add a new / different widget to the home page.) Those 3 widgets were defined with a similar create statement in the function.php page..and that worked as it should, creating the ‘shell’ of the widget to be available for customisation in the admin area. The code that displayed those three widgets on the home page were written as follows:
FRONT-PAGE.PHP:
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="thumbnail-kenburn thumbnail-kenburnl">
<?php if ( dynamic_sidebar ( 'front-left' ) ); ?>
</div>
</div>
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="thumbnail-kenburn thumbnail-kenburnc">
<?php if ( dynamic_sidebar ( 'front-center' ) ); ?>
</div>
</div>
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="thumbnail-kenburn thumbnail-kenburnr">
<?php if ( dynamic_sidebar ( 'front-right' ) ); ?>
</div>
</div>
</div>
I know you are saying that the code isn’t correct.. yet it does call in the correct widgets as defined in the function.php file.
I don’t see an action hook in the Oasis site’s function.php.. this one does work.. so I am not sure how it does what it does? I’ll display the entire file so maybe you can see where the action call might be??
FUNCTION.PHP:
<?php
function theme_styles() {
wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'theme_styles' );
function theme_js() {
global $wp_scripts;
wp_register_script( 'html5_shiv', 'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', "", "", false );
wp_register_script( 'respond_js', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', "", "", false );
$wp_scripts->add_data( 'html5_shiv', 'conditional', 'lt IE 9' );
$wp_scripts->add_data( 'respond_js', 'conditional', 'lt IE 9' );
wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );
wp_enqueue_script( 'theme_js', get_template_directory_uri() . '/js/theme.js', array('jquery', 'bootstrap_js'), '', true );
wp_enqueue_script( 'stickynav_js', get_template_directory_uri() . '/js/stickynav.js', array('jquery'), '', true );
}
add_action( 'wp_enqueue_scripts', 'theme_js', 'stickynav_js' );
//add_filter( 'show_admin_bar', '__return_false' );
add_theme_support( 'menus' );
add_theme_support( 'post-thumbnails' );
function register_theme_menus() {
register_nav_menus(
array (
'header-menu' => __( 'Header Menu' )
)
);
}
add_action( 'init', 'register_theme_menus' );
add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
add_post_type_support( 'page', 'excerpt' );
}
function create_widget( $name, $id, $description, $beforewidget, $beforetitle, $aftertitle ) {
register_sidebar(array(
'name' => __( $name ),
'id' => $id,
'description' => __( $description ),
'before_widget' => $beforewidget,
'after_widget' => '</div>',
'before_title' => $beforetitle,
'after_title' => $aftertitle,
));
}
create_widget( 'Front Page Left', 'front-left', 'Displays on the left of the homepage', '<div class="widget">', '<h3>', '</h3>' );
create_widget( 'Front Page Center', 'front-center', 'Displays in the center of the homepage', '<div class="widget">', '<h3>', '</h3>' );
create_widget( 'Front Page Right', 'front-right', 'Displays on the right of the homepage', '<div class="widget">', '<h3>', '</h3>' );
create_widget( 'Front Page Sidebar', 'front-side', 'Displays sidebar after header image', '<div class="widget sider">', '<div class="headline"><h3>', '</h3></div>' );
create_widget( 'Footer Left', 'footer-left', 'Displays on the left of the footer', '<div class="widget">', '<h2>', '</h2>' );
create_widget( 'Footer Center', 'footer-center', 'Displays in the center of the footer', '<div class="widget">', '<h2>', '</h2>' );
create_widget( 'Footer Right', 'footer-right', 'Displays on the right of the footer', '<div class="widget">', '<h2>', '</h2>' );
create_widget( 'Page Sidebar', 'page', 'Displays on the side of pages with a sidebar', '<div class="widget blog-twitter">', '<div class="headline"><h3>', '</h3></div>' );
create_widget( 'Page Sidebar contact', 'page2', 'Displays on the side of pages with a sidebar with contact button', '<div class="widget">', '<h3>', '</h3>' );
create_widget( 'Page Sidebar short', 'short-testimonial', 'Displays on the side of short pages', '<div class="widget blog-twitter">', '<div class="headline"><h3>', '</h3></div>' );
create_widget( 'Page Sidebar about', 'about-side', 'Displays on the side of the About page', '<div class="widget">', '<h3>', '</h3><br /><br />' );
create_widget( 'Page Sidebar theory', 'theory-side', 'Displays on the side of the Aviation Theory page', '<div class="widget">', '<h3>', '</h3><br /><br />' );
create_widget( 'Page Sidebar trial', 'trial-side', 'Displays on the side of the Trial Introductory Flight page', '<div class="widget">', '<h3>', '</h3><br /><br />' );
create_widget( 'Blog Sidebar', 'blog', 'Displays on the side of pages in the blog section', '<div class="widget">', '<h3>', '</h3>' );
create_widget( 'Off-Canvas Sidebar', 'offcanvas', 'Displays on the side of pages with an off-canvas sidebar', '<div class="widget">', '<h3>', '</h3>' );
function ninja_forms_add_nf_styles( $form_id ) {
if( $form_id == 1 ) {
// echo '<style>
// .ninja-forms-form-wrap{background:red}
// </style>';
wp_enqueue_style( 'ninja_forms-nf-css', get_template_directory_uri() . '/css/ninja_forms.css' );
}
}
add_action ( 'ninja_forms_display_css', 'ninja_forms_add_nf_styles' );
?>
So why does this code work for the Oasis site.. and not for the new site. They both have the same code structure.
Can you give me any insight in how to fix the new site?
Thanks,
SunnyOz
-
This reply was modified 5 years, 2 months ago by
SunnyOz. Reason: tried to provide link to website referenced