WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to: make a blogpage!? (3 posts)

  1. dekraan
    Member
    Posted 5 years ago #

    Hello all, please take a look at my site over here. Do not mind the look, I am tinkering with it.

    This is my menu, which will show you - I hope - how strange my theme works:

    <ul id="menu">
    <li><a href="<?php bloginfo('url'); ?>">Home</a></li>
    <li><a href="/blog/overons">About</a></li>
    <li><a title="Copyright information" href="/blog/watwedoen/">What we do</a></li>
    <li><a href="<?php echo get_category_link($blog_category_page); ?>">Blog</a></li>
    <li><a href="blog/contact">Contact</a></li>
    </ul>

    So, first: home, then (to keep the order) with permalinks 2 more pages, followed by a blogcategory, and a last page, contact.

    The problem is this: I like the way my site looks now, with the pages I can fill in, and one blogcategory. I just want to change the blogcategory, into a blogpage. So: I want to have a page that does what my blogcategory now does. But how? How do you get a page, that displays all your posts? I already have page-blog.php in my files, so I can switch a page from default into blog. I just don't know what to put there. Who can help?

    To sum up: I have some pages, like contact etc. Then, I also have a blogcategory, where all my posts go. I want to make a page out of this, by going 'pages - add new' and naming this 'Blog', to replace the category 'blog'. I think that for doing this, I should change the template from default (page.php) to blog, which is page-blog.php. But what should I put on page-blog.php besides 'get header, get footer, get sidebar?

    I am not a good coder. Please, if anyone knows, explain it very clearly. Thank you all in advance! Theme can be sent to you, just let me know!

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    Create a new custom page template. Just before the call to header.php, add <?php global $more;?> (needed to access the 'more' tag on a page).

    Just before the start of The Loop, add <?php query_posts('category_name=your_category_name');?>.

    Amend <?php the_content();?> to <?php $more = 0;the_content();?> (this is the second step that you need to add to force the 'more' tag to work on a page).

    Save and upload the new template. Publish a new page - using this template - with the title that you want.

  3. dekraan
    Member
    Posted 5 years ago #

    Hello Esmi, I think I did what you asked. The page I used as an example (not to make everything change) is contact.

    This is the code that I used for the template 'blog' (which I changed on contact from the default-page):

    <?php /*
    	Template Name: Blog
    */ ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    	<head profile="http://gmpg.org/xfn/11">
    		<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
    
    		<!-- Meta -->
    		<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    		<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
    		<meta name="keywords" content="<?php bloginfo('description'); ?>" />
    		<meta name="description" content="<?php bloginfo('description'); ?>" />
    
    		<!-- Stylesheets, XML &amp; Pingback -->
    		<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory');?>/style.css" type="text/css" media="screen" />
    		<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    		<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    
    		<!-- Javascripts -->
    		<script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/top.js"></script>
    		<script type="text/javascript">
    		<!--//--><![CDATA[//><!--
    		   function m(el) {
    		      if ( el.defaultValue == el.value ) el.value = "";
    		}
    		//--><!]]>
    		</script>
    
    		<?php
    		// Category Sort options
    		global $categories_sort;
    		if(get_settings('Shade_sortcategories')!='')
    		{
    			$categories_sort = 'sort_column='. get_settings('Shade_sortcategories');
    		}
    
    		// Exclude Categories options
    		global $categories_to_exclude;
    
    		if(get_settings('Shade_excludecategories')!='')
    		{
    			$categories_to_exclude = 'exclude='. get_settings('Shade_excludecategories');
    		}
    		?>
    		<?php wp_head(); ?>
    <?php wp_head(); require("config.php"); ?>
    	</head>
    	<body>
    <?php global $more;?>
    		<div id="header">
    			<div class="header">
    				<a href="<?php echo get_option('home'); ?>/"><img src="<?php echo get_option('home'); ?>/wp-content/themes/shade/img/logo.gif" alt="Logo" /></a>
    <ul id="menu">
    <li><a href="<?php bloginfo('url'); ?>">Home</a></li>
    <li><a href="/blog/overons">Over Ons</a></li>
    <li><a title="Copyright information" href="/blog/watwedoen/">Wat We Doen</a></li>
    <li><a href="<?php echo get_category_link($blog_category_page); ?>">Blog</a></li>
    <li><a title="Copyright information" href="../contact">Contact</a></li>
    </ul>
    			</div>
    		</div>
    		<div class="intro">
    			<div style="margin:0 auto; width:960px;">
    				<form class="search-header" method="get" style="margin:0px;" action="<?php echo get_option('home'); ?>/">
    					<input value="See what you can find..." onfocus="if(this.value == 'See what you can find...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'See what you can find...';}" style="margin:5px 0px 0px 10px;" type="text"  name="s" id="s" size="19" class="search-top" />
    					<input type="image" src="<?php echo get_option('home'); ?>/wp-content/themes/shade/img/spacer.gif" style="margin:0px; padding:0px; border:0px;width:30px;height:30px;" />
    				</form>
    				<div class="intro-title"><?php the_title2('', '', true, '46') ?></div>
    			</div>
    		</div>
    		<div id="container">
    			<div id="wrapper">
    				<?php include 'sidebar.php';?>
    				<div id="content" class="narrowcolumn">
    <?php query_posts('category_name=your_category_name');?>
    				<?php if (have_posts()) : ?>
    					<?php $post = $posts[0];  ?>
    					<div class="post">
    						<div class="entry">
    						<?php while (have_posts()) : the_post(); ?>
    							<div style="text-align:justify;">
    								<?php $more = 0;the_content(); ?>
    								<?php comments_template(); // Get wp-comments.php template ?>
    						<?php endwhile; ?>
    							</div>
    						</div>
    					</div>
    				<?php else : ?>
    					<?php include (TEMPLATEPATH . '/notfound.php');?>
    				<?php endif; ?>
    				</div>
    <?php get_footer(); ?>

    But it doesn't really work yet. What did I do wrong? It displays my 404-page. If you want to take a look in my coding, just ask!

Topic Closed

This topic has been closed to new replies.

About this Topic