Creating custom page templates - wordpress

I have just created my "About Us" page inside WP Admin Dashboard, that points to an about-us.php page template that I created and has a empty div content, i.e.
<div id="content"></div>
It is in here where I would like to grab the content that the wp-admin user enters in the dashboard About Us page and place this content within my
<div id="content">[Dashboard About Us Page Content to go Here]</div>
Basically want to take the whole content from the "About Us" WordPress page and feed this into my about-us.php page template content DIV.
How can I achieve this?

<?php if(have_posts()): while(have_posts()): the_post();
the_content();
endwhile; endif; ?>
Stick that inside the empty div and it will pull the content in dynamically. Read more about the loop here:
http://codex.wordpress.org/The_Loop

Related

How to Create static Page for navigation bar in custom wordpress theme

I have a Home Page(index.php) in my custom wordpress page . In Home page i have a horizontal navigation bar where i have a "contact us" section since i am new to wordpress development i dont know how to create contact us in wordpress.
code of my contact us page is
<?php/* This is contact page of SampleTheme */
?>
<?php
get_header();
?>
<div class="EventCalender"> <?php echo do_shortcode(' [do_widget id=spider_calendar-2]'); ?> <br>
<p class="EventCalenderPara"> There are 13 Planed events!! We all hope<br>
to see you and your family there! </p></div>
<?php get_footer(); /?>
when i run this page by runing url "localhost/wordpress/contact.php" i am getting 404 error. I have only index,header,footer,function,contact pages in my custom wordpress theme
"localhost/wordpress/contact.php" -- It is wrong. you can create a new contact page then run this url "localhost/wordpress/contact" if your contact page name is "contact"
If you want to create custom page follow this
use this top of your contact.php page
<?php
/* Template Name:Contact*/
?>
Then go to dashboard -> pages -> edit contact page (if not exist create a new page) -> from right sidebar click template name and choose Contact. save and run

how do i add different custom right sidebars with different widths and content on different pages in wordpress?

i everyone i have afew pages in wordpress that i need different custom right sidebars on with different css styles. for example i would like my homepage right sidebar to be a set width say 100px and displaying specific content and id like to have my special offers page with a right sidebar thats a different width say 230px displaying different content like widgets etc...
to my understanding this should be able to be achieved by creating custom sidebars by registering them with a wordpress function and then creating a custom sidebar template php file with a different css class for the sidebar. and then calling the new custom sidebar template file inside of a custom page template file being applied to a target page in wordpress so that the page loads the custom sidebar template instead of the normal sidebar template with a new css class that can be modified to achieve different sidebar styles for different pages. so i created the following custom sidebar template and called it customrightsidebar.php
<div id="sidebar3"><div class="sidebar3"><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('customright-sidebar') ) : ?><div class="customright-sidebar"><h4>Recent Posts</h4><ul><?php wp_get_archives('type=postbypost&limit=5'); ?> </ul></div><?php endif; ?></div> <br style="clear:both"></div>
i then registered a new custom sidebar using this function
register_sidebar(array('name'=>'customright-sidebar','before_widget' => '<div class="customright-sidebar">','after_widget' => '</div>','before_title' => '<h4>','after_title' => '</h4>',));
and here is the custom page template that is calling the custom sidebar template
<?php get_header(); ?><div id="breadcrumb"><?php breadcrumbs(); ?></div>
<?php include(TEMPLATEPATH."/customrightsidebar.php");?>
<div id="kontenutama"> <div class="postingan2"><?php if (have_posts()) : while (have_posts()) : the_post(); ?><h2><?php the_title(); ?></h2><?php the_content(); ?><?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?><br style="clear:both;"></div></div>
<br style="clear:both"><div style="clear:both"></div><?php get_footer()?>
i successfully have a custom right sidebar that appears in my wordpress admin panel and i can apply widgets to it in the widgets section of my admin panel i can also see it appear in the custom sidebar dropdown selection menu in my wordpress pages where you would specify your new custom sidebars to overwrite the old ones. you can see a screenshot of the sidebar selection boxes in my theme by visiting this url
http://test.smartphonesource.org/sidebars.png
and normally by selecting it it would overwrite the default sidebars on the page
i have been able to get the custom sidebar template to load with the custom class on the page and ive been able to edit the css but the actual custom sidebar itself with its widgets isnt appearing or overwriting anything even though ive selected it to overwrite the right sidebar of the current page in the custom sidebars selection box
im not sure where to go from here or if there is a different way to do this i think somewhere the customsidebar isnt overwriting the default right sidebar when its been selected in the custom sidebar selection box on my pages im new to wordpress and php. ive been able to use the customright-sidebar on my videos page for testing and it successfully overwrote the right sidebar and worked but it was running this default right sidebar template
<div id="sidebar2"><div class="sidebar2"><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Right') ) : ?><div class="left-sidebar"><h4>Recent Posts</h4><ul><?php wp_get_archives('type=postbypost&limit=5'); ?> </ul></div><?php endif; ?></div> <br style="clear:both"></div>
anyhelp would be greatly appreciated figuring this out =) you can see the homepage of the site here that im using to learn wordpress and from there you can navigate to the videos and special offers page that im tearing apart to get a better idea of what im trying to do with the sidebars
http://test.smartphonesource.org
First of all, your website looks really awesome:) And to fix this did you make sure that your page is only grabbing the new sidebar code only?
i managed to fix the page issue im not sure what was wrong but it suddenly started working with the same code i know i cleared my cache so maybe that was affecting it or preventing the new changes from appearing sometimes if i dont clear the cache after i upload new images they wont display for me

Single Page Wordpress Template

I have to convert the following HTML website into a Theme for Wordpress. I am trying to figure out how to structure the theme in terms of pages/posts/custom modules and themes.
I have 5 sections in my page
Home (Slider and content)
Know (tabs with content)
View (Projects with filterable effect)
Read (blog and articles)
Talk (contact Form)
I want to allow the customer to be able to edit most of the content on the page.
Please guide me into getting started.
Link: http://play.mink7.com/sophiance/
*Edit*
I created a page called 'home' and in settings>reading> selected that as the static content for the site.
Next i created a template called template-home.php and selected the home to use this template.
in your index.php file put the 5 sections.
in each section - create a new query to pull a page.
for example with a custom post type
<section id="home">
//Slider Content
<?php query_posts('pagename=home'); if ( have_posts() ) while ( have_posts() ) : the_post(); ?>//Loop Content
<?php endwhile; endif; wp_reset_query(); ?>
</section>
<section id="know">
<?php query_posts('pagename=know'); if ( have_posts() ) while ( have_posts() ) : the_post(); ?>//Loop Content
<?php endwhile; endif; wp_reset_query(); ?>
</section>
etc.
Then create each page with that name and it will pull the data
I created a site like that here
This is how you should structure your Wordpress website:
Home (Slider and content) - create a page called Home and a custom page template called home
Know (tabs with content) - use a shortcode plugin to have tabbed content, default page template
View (Projects with filterable effect) - use a plugin that displays content in a masonry layout, default page template
Read (blog and articles) - create posts (under posts) and display them using the post archive.
Talk (contact Form) - use default page template and a plugin like Gravity Themes for the contact form
For similar ideas on how to structure your Wordpress website go to http://www.mybuzzmedia.net

Same editable region/content same on all pages

I'm working on this website in WordPress and I want the content with the title "Featured Business" that's on the sidebar to appear on all pages. I created a template for it but it doesn't display when called. The code is as shown below.
<div id="ftb">
The content
</div>
<!-- End FTP -->
and I called it with <?php get_ftb(); ?> But it doesn't show.
If you want to display a chunk of html that's part of the sidebar (but not the entire sidebar), I recommend to place it on functions.php, like this:
<?php
function get_ftb() {
?>
<div id="ftb">
The content
</div>
<!-- End FTP -->
<?php } ?>
After that you'll be free to call it with get_ftb();
If you just need to call the entire sidebar, use get_sidebar() instead.

How to display a different sidebar for all blog posts and on the page where the blogs are listing?

I have a WordPress site which have 4 pages with one page is a blog page.
I have created a page template for the blog page to display all blogs on this page.
On this page template I am displaying the different sidebar from the other pages.
This sidebar displaying the blog archives.
But when I click on an archive the sidebar changes to the that first sidebar which is also on another pages.
How will I remain this second sidebar to be display on every blog post?
In case of custom pages, for example, we are having aboutus.php having body contents like this:
<?php
/**
* Template Name: About us
*
* Selectable from a dropdown menu on the edit page screen.
*/
?>
<?php get_header(); ?>
//body content for aboutus page
<?php include ('aboutus_sidebar.php'); ?>//separate sidebar for aboutus
<?php get_footer(); ?>
Then, create a file named aboutus_sidebar.php with whatever you want.

Resources