WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] index.php displaying extra info that is not wanted.... (13 posts)

  1. Kevin Kwok
    Member
    Posted 4 years ago #

    basically my site ( ampersandbox.net )
    the index.php file is coded to display 4 things, default home page, organize posts by newest, featured and random

    I also wanted to create a custom page for the "about" link on the top right. i did this by adding more to my existing php code on index.php here is the code:

    if(isset($_GET['pg']))
    	{
    		if($_GET['pg'] == "about")
    		{
    		//////////////////////////////////////////////////////////////////////////////////////////
    		echo "
    			About ampersandbox:
    			<BR /><BR />
    			Ampersandbox is a project made for graphic designers to be creative without the <BR />
    			restraints of clients and classrooms, but within the parameters of an assignment.<BR />
    			Consider this your playground. A place to design and have fun doing it.<BR />
    			<BR />
    			Rules for play:<BR />
    			<BR />
    			1. New assignments will be posted every week.<BR />
    			2. All work must be submitted as .jpg or .gif format, 72 pixels, 640 x 480.<BR />
    			3. Your first four assignments are required, and must be submitted within a week of<BR />
    			receiving your invitation.<BR />
    			4. Once you have completed your four required assignments, you are welcome to<BR />
    			contribute to any past or future assignments, and at your own leisure.<BR />
    			<BR />
    			<BR />
    			<BR />
    			Ampersandbox was created by Marian Chiao as an independent-study project, instructed<BR />
    			by Simon Johnston, at Art Center College of Design, in the Fall of 2009. ";
    
    		echo  '"Assignments"';
    		echo "<BR />
    			inspired by the community art project Learning to Love You More by artists<BR />
    			Miranda July and Harrell Fletcher. Website built by Kevin Kwok.
    			<BR /><BR /><BR /><BR /><BR /><BR /><BR /><BR /><BR />
    			";
    
    		echo '<div style="float: right; position:absolute; padding-left:690px; padding-right:10px; font-family:Courier New; font-size:16px; width:180px;">
    			<a href="mailto:info@ampersandbox.net">info@ampersandbox.net</a></div>';
    
    		////////////////////////////////////////////////////////////////////////////////////////////
    		}
    		}

    the link to the about page: http://ampersandbox.net/?pg=about

    it displays the content of the "about" page i coded just fine.. however it also displays posts below which i do not want. can someone please tell me what i am doing wrong =(

    here is the code for my whole index.php file http://wordpress.pastebin.ca/1658025

  2. Kevin Kwok
    Member
    Posted 4 years ago #

    still cant figure out what i am doing wrong, please help if you can. thank you in advance.

  3. kiano.ro
    Member
    Posted 4 years ago #

    how did you make that about page? throw your wordpress admin panel?

  4. Kevin Kwok
    Member
    Posted 4 years ago #

    the about page code is from the code listed above

  5. kiano.ro
    Member
    Posted 4 years ago #

    again: how did you did it? did you go to the admin panel -> pages -> add new?

  6. Kevin Kwok
    Member
    Posted 4 years ago #

    again, it was listed above but here it is now. this is how i added the code this is all the about page in this code i put on the index.php

    if(isset($_GET['pg']))
    	{
    		if($_GET['pg'] == "about")
    		{
    		//////////////////////////////////////////////////////////////////////////////////////////
    		echo "
    			About ampersandbox:
    			<BR /><BR />
    			Ampersandbox is a project made for graphic designers to be creative without the <BR />
    			restraints of clients and classrooms, but within the parameters of an assignment.<BR />
    			Consider this your playground. A place to design and have fun doing it.<BR />
    			<BR />
    			Rules for play:<BR />
    			<BR />
    			1. New assignments will be posted every week.<BR />
    			2. All work must be submitted as .jpg or .gif format, 72 pixels, 640 x 480.<BR />
    			3. Your first four assignments are required, and must be submitted within a week of<BR />
    			receiving your invitation.<BR />
    			4. Once you have completed your four required assignments, you are welcome to<BR />
    			contribute to any past or future assignments, and at your own leisure.<BR />
    			<BR />
    			<BR />
    			<BR />
    			Ampersandbox was created by Marian Chiao as an independent-study project, instructed<BR />
    			by Simon Johnston, at Art Center College of Design, in the Fall of 2009. ";
    
    		echo  '"Assignments"';
    		echo "<BR />
    			inspired by the community art project Learning to Love You More by artists<BR />
    			Miranda July and Harrell Fletcher. Website built by Kevin Kwok.
    			<BR /><BR /><BR /><BR /><BR /><BR /><BR /><BR /><BR />
    			";
    
    		echo '<div style="float: right; position:absolute; padding-left:690px; padding-right:10px; font-family:Courier New; font-size:16px; width:180px;">
    			<a href="mailto:info@ampersandbox.net">info@ampersandbox.net</a></div>';
    
    		////////////////////////////////////////////////////////////////////////////////////////////
    		}
    		}
  7. Kevin Kwok
    Member
    Posted 4 years ago #

    this part is key

    if($_GET['pg'] == "about")

    meaning when ?pg=about is called anything under that if statement will display the text below

  8. kiano.ro
    Member
    Posted 4 years ago #

    but i dont understand why did you add it like that. Why didnt you add your page throw your admin panel?

  9. Kevin Kwok
    Member
    Posted 4 years ago #

    I did it this way because the about page is different than other pages i will have in the future, it has different forms, etc

  10. henkholland
    Member
    Posted 4 years ago #

    queesy: everything you put in you index.php wil be visible when that file is called for. (and yo will loose it after a theme cahnge or upgrade).
    Go into Admin and make a new PAGE (not POST) call it ABOUT ME and get it accessible from your menu.

  11. Kevin Kwok
    Member
    Posted 4 years ago #

    not entirely true. when i added this code before

    elseif($_GET['sortall'] == "random")	// random listing
    		{
    			echo "random";
    		}

    when random was clicked it only displayed "random"
    and no posts. so i think its totally possible but thank you for your input.

  12. Kevin Kwok
    Member
    Posted 4 years ago #

    ha! just got it to work... thanks for um
    telling me i couldnt? haha heres the code

    if(isset($_GET['pg']))
    	{
    		if($_GET['pg'] == "newest")	// newest listing
    		{
    			$postslist = get_posts('numberposts=1');
    			foreach ($postslist as $post){
    			setup_postdata($post);
    				echo thematic_indexloop();
    			}
    		}
    		elseif($_GET['pg'] == "featured")	// featured listing
    		{
    			printr(featuredpostsList());
    		}
    		elseif($_GET['pg'] == "random")	// random listing
    		{
    			$postslist = get_posts('orderby=rand&numberposts=0');
    			foreach ($postslist as $post){
    			setup_postdata($post);
               		echo '<div id="post-';
    				echo the_ID(). '" style="width:670px";>';
    				echo '<div class="entry-content">';
    				echo childtheme_post_header(). '<a href="';
    				echo  the_permalink(). '"rel="bookmark">';
    				echo '<span class="slide-title" style=" font-family:Courier New; font-size:11px;">';
    				echo get_post_meta($post->ID, 'designed-by', $single = true). '<div style="width:145px; position:inherit; top:0px; " align="right">';
    				echo the_title(). '</div></span><img class="full-image" src="';
    				echo get_post_meta($post->ID, 'full-image', $single = true);
    				echo '" width="150" height="113"></a></div></div>';
    				}
    		}
    
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    		elseif($_GET['pg'] == "about")	// about page
    		{
    		//////////////////////////////////////////////////////////////////////////////////////////
    		echo '<div style="float: right; position:absolute; padding-left:690px; padding-right:10px; font-family:Courier New; font-size:11px; width:180px;">
    			<a href="mailto:info@ampersandbox.net">info@ampersandbox.net</a></div>';
    
    		echo "
    			About ampersandbox:
    			<BR /><BR />
    			Ampersandbox is a project made for graphic designers to be creative without the <BR />
    			restraints of clients and classrooms, but within the parameters of an assignment.<BR />
    			Consider this your playground. A place to design and have fun doing it.<BR />
    			<BR />
    			Rules for play:<BR />
    			<BR />
    			1. New assignments will be posted every week.<BR />
    			2. All work must be submitted as .jpg or .gif format, 72 pixels, 640 x 480.<BR />
    			3. Your first four assignments are required, and must be submitted within a week of<BR />
    			receiving your invitation.<BR />
    			4. Once you have completed your four required assignments, you are welcome to<BR />
    			contribute to any past or future assignments, and at your own leisure.<BR />
    			<BR /><BR /><BR />
    			Ampersandbox was created by Marian Chiao as an independent-study project, instructed<BR />
    			by Simon Johnston, at Art Center College of Design, in the Fall of 2009. ";
    
    		echo  '"Assignments"';
    		echo "<BR />
    			inspired by the community art project Learning to Love You More by artists<BR />
    			Miranda July and Harrell Fletcher. Website built by Kevin Kwok.
    			<BR /><BR /><BR /><BR /><BR /><BR />
    			";
    		echo '
    			<div style="position:absolute;margin-left:-10px;height: 1px; width: 660px; background-color: #000000; margin-top:-5px; margin-bottom: 15px;"">
    			</div><BR /><BR />';
    
    		////////////////////////////////////////////////////////////////////////////////////////////
    		}
    
    	}
    	else
    	{
    		// default index - show categories with thumbnails for each
    		// Modifications by Edward Wong
    			// The following code obtains the variable "sortby" via the "get method" in PHP.
    			// notice the index.php?sortby=ASC or DESC
    
    			// This if statement checks if the variable is set or not
    			// if it's not set, it'll give it the default value of ASC
    			if(!isset($sortby))
    			{
    				$sortby = 'DESC';
    			}	
    
    			$cat_args = array(
    								'orderby' => 'ID',
    								'order' => $_GET[sortby]	// New Code
    							  );
    			$categories = get_categories($cat_args);
    			foreach($categories as $category)
    			{
    				echo '<div>';
    				echo '<div style="float: right; position:absolute; padding-left:690px; padding-right:10px; font-family:Courier New; font-size:11px; width:180px;">
    				<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "" )) . '" ' . '>' . $category->name. ' '.$category->description.'</a></div>';
    				$args = array(
    								'orderby' => 'ID',
    								'order' => 'DESC',
    								'showposts' => -1,
    								'category' => $category->term_id,
    								'caller_get_posts' => 1
    							  );
    				$posts = get_posts($args);
    				echo '<div style="float: left; width: 660px;">';
    				foreach($posts as $post)
    				{
    					setup_postdata($post);
    					childtheme_post_header();
    					echo "<a href=\"".$post->guid."\" rel=\"bookmark\">";
    					echo '<div style="float: left; width: 150px; margin-right: 15px;">';
    
    					if(get_post_meta($post->ID, 'full-image', $single = true))
    						echo '<img class="full-image" src="'.get_post_meta($post->ID, 'full-image', $single = true).'" width="150" height="113" /><BR />';
    					else
    						echo '<img class="full-image" src="'.bloginfo('url').'" width="150" height="113" /><BR />';
    						echo '<div style="height:50px;">
    								<div style="float: left; margin-top:6px;">'.get_post_meta($post->ID, 'designed-by', $single = true).'</div>
    								<div style="float: right; margin-top:6px;">'.$post->post_title.'</div>
    								<div style="clear: both;"></div>
    							  </div>';
    					echo '</div>';
    					echo '</a>';
    				}
    				echo '</div>';
    				echo '<div style="clear: both;"></div>';
    				echo '</div>';
    				echo '
    				<div style="position:absolute;margin-left:-10px;height: 1px; width: 660px; background-color: #000000; margin-top:-5px; margin-bottom: 15px;""></div>
    				<div style="position:absolute;margin-left:680px;height: 1px; width: 200px; background-color: #000000; margin-top:-5px; margin-bottom: 15px;"></div>
    				<br />';
    			}
    	}
    
    ?>
            </div>

    hope this helps someone

  13. henkholland
    Member
    Posted 4 years ago #

    Ok, thumbs up (I mean that). You are a great coder and I don't know that much about coding, apart from thinking that there is a very simple built in way in WordPress to do an about page. Just make a page and a menu link and you are update proof too that way.

    Greetings, Henk

Topic Closed

This topic has been closed to new replies.

About this Topic