Can you add Posts to a wordpress page?

16 replies
  • WEB DESIGN
  • |
I want to display all new wordpress posts on a members page that members come to after they login. Like a dashboard page. I don't want it in the sidebar but on the main content area of a page. I am using WishList member.

Is there a way to have all posts show up on a page (not the home page)? Is there a piece of code that can be added to a page?

Thanks for the help,
Scott
#add #page #posts #wordpress
  • Profile picture of the author layouts4you
    in the wordpress admin you can specify the home page as static and make a new page for the posts called blog or what not and specify that you want all posts on that page instead of the home page.
    {{ DiscussionBoard.errors[2317744].message }}
  • The following code will display all posts from the current member. Add this code to the .php file that displays the member's page. (I don't know how you have your page set up, but I would recommend a page template for your member's page that contains this code at the end of the code.)

    Code:
    <?php $current_user = wp_get_current_user(); $query_string='';?>
    <?php query_posts('post_author='.$current_user->ID); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
    
    	<!--PUT ADDITIONAL LOOP INFO HERE (e.g., the_title(), the_author, etc.)-->
    
    <?php endwhile; else: ?>
    
    <p>Sorry, you have no posts.</p>
    
    <?php endif; ?>
    {{ DiscussionBoard.errors[2317820].message }}
  • Profile picture of the author HighPowerSites
    Thanks guys.

    I know how to set the homepage as static and set a posts page but me homepage is customized so it doesn't work.

    Chris:

    I want to show all posts made by me on the member's page, not the particular user just posts made by me as I am the only one posting. Is there code for that?
    {{ DiscussionBoard.errors[2317843].message }}
  • Profile picture of the author layouts4you
    can you just change the page for the posts then and not change the home page to static or do you need posts on home page also.
    {{ DiscussionBoard.errors[2317850].message }}
  • Profile picture of the author HighPowerSites
    No, I don't need posts on the homepage. It is a sales page but when I choose to make the members page as my posts page, it screws up the homepage.
    {{ DiscussionBoard.errors[2317857].message }}
  • If you are the only one who posts, then the following code would work:

    Code:
    <?php query_posts($query_string=''); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
    
    	<!--PUT ADDITIONAL LOOP INFO HERE (e.g., the_title(), the_author, etc.)-->
    
    <?php endwhile; else: ?>
    
    <p>Sorry, there are no posts.</p>
    
    <?php endif; ?>
    {{ DiscussionBoard.errors[2317866].message }}
  • Profile picture of the author HighPowerSites
    Chris:

    Which page should I add this to?

    Thanks alot,
    Scott
    {{ DiscussionBoard.errors[2317874].message }}
  • Profile picture of the author layouts4you
    i posted my contact info on the other post of your. skype jasonaud or yahoo jasonaud2804. msg me and ill help you all i can.
    {{ DiscussionBoard.errors[2317913].message }}
  • What page do members go to after they login? Do you have a specific "Page Template" for this page? If not, then this is what I would do...

    1. Create a page template - Copy and paste the code below and the contents of your Wordpress theme's "page.php" file into a new file and save it as "member-page.php".

    Code:
    <?php
    /*
    Template Name: Member
    */
    ?>
    
    /*COPY AND PASTE YOUR PAGE.PHP CODE HERE*/
    2. Paste the following code in the "members-page.php" file where you want your posts to appear:

    Code:
    <?php query_posts($query_string=''); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
    
    	<!--PUT ADDITIONAL LOOP INFO HERE (e.g., the_title(), the_author, etc.)-->
    
    <?php endwhile; else: ?>
    
    <p>Sorry, there are no posts.</p>
    
    <?php endif; ?>
    3. Upload the "members-page.php" file to your theme's directory and select it as a "Page Template" under WP-Admin->Edit Pages->Title of the Page Your Members Access After Login.

    Don't hesitate to ask if you have any additional questions.
    {{ DiscussionBoard.errors[2317919].message }}
  • I forgot to tell you... When you paste the code (Step #2 above) into your "members-page.php" file, make sure you place it beneath the main Loop code.
    {{ DiscussionBoard.errors[2317937].message }}
    • Profile picture of the author HighPowerSites
      Originally Posted by Chris Landrum View Post

      I forgot to tell you... When you paste the code (Step #2 above) into your "members-page.php" file, make sure you place it beneath the main Loop code.
      Not sure what you meant but it seems to be working.

      Thanks alot.

      Once other question not sure if either of you can answer:

      I integrated my WishList member with ClickBank and upon testing, I am brought back to my site where the user needs to input their username and password. The problem is that even before they input and register with a username and password they seem to be able to access areas only viewable to logged in members. They are essentially members without having to add their username and password info. How can I keep those pages from showing until they actually register with their username and password?

      I know this is in test mode but it is not supposed to actually make them a member until they register.
      {{ DiscussionBoard.errors[2318086].message }}
  • Profile picture of the author layouts4you
    perfect answer Chris. hes still at the issue im trying to figure out for him. he doesnt want the posts on the home page from what im gathering. are you aware of any way to remove the posts from the home page without having to make it a static page.
    {{ DiscussionBoard.errors[2317955].message }}
  • While I can only guess how the theme's code is set up, you could exclude the posts from the home page like this...

    Code:
    <?php if(!is_home()){?>
    <?php query_posts($query_string=''); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
    
    	<!--PUT ADDITIONAL LOOP INFO HERE (e.g., the_title(), the_author, etc.)-->
    
    <?php endwhile; else: ?>
    
    <p>Sorry, there are no posts.</p>
    
    <?php endif; } ?>
    {{ DiscussionBoard.errors[2317978].message }}
  • Profile picture of the author layouts4you
    ok thats what i was thinking also. thanks for the input also. helped me out in some things i do also. i always do the static home page and put posts on other page.

    hope this all helps you out highpower.
    {{ DiscussionBoard.errors[2317997].message }}
  • You're welcome. I'm glad I could be of help.

    "query_posts" is a useful function to experiment with for Wordpress development.

    Here's where you can find out more about it:
    Function Reference/query posts WordPress Codex
    {{ DiscussionBoard.errors[2318017].message }}
  • Profile picture of the author layouts4you
    do you have the content protected with the wishlist program. if it isnt part of the members area then they will be able to access them.

    here is some info on wishlist that might help you


    WishList Products Customer Center Support Videos (New)

    hopefully these 2 videos will help you with wishlist.
    {{ DiscussionBoard.errors[2320142].message }}

Trending Topics