• Is there a way to set a specific post to be the homepage everytime someone visits my main URL instead of my most recent post?

Viewing 13 replies - 31 through 43 (of 43 total)
  • I edit with 2 other people on the site.

    I’d rather not have to ask them to edit the php on the web server with each posting.

    With a redirect, any web author has UI within wordpress to edit the target URL.

    I am getting confused… or you made it confusing…

    If you always want the lates post on your main/home page – then forget the whole thing hakre made you to go through and go back to my post when I gave you exactly that solution.
    Set the blog to show 1 post.
    Use the plugin to have different number of posts on other pages.
    (and don’t argue about the plugin BEFORE you try it!)

    Plus, if you want to show the comments and comment form on the main/index/front page – go and read all those search results I gave you.

    What is so complicated?

    p.s. hakre’s solution works if you want to keep always the same post on your main page.

    EDIT. Forget the obsession with redirect… In your case that just does NOT MAKE ANY SENSE.

    I tried it. moshu, I also read all those pages in the search results. I’m telling you, there is no solution there. I looked. What I did find is a number of threads where the problem wasn’t solved. And in a number of them there were posts where you also pointed people at the search results. I didn’t find any solution presented.

    Some of the knowledge you have shared here was helpful. Thank you.

    The redirect works. And hakre’s solution works.

    Maybe I’ll have to go send my web authors into cPanel and use the option to edit a file within file manager. But something tells me that the redirect is less risky.

    OK. Let’s get back to the basics.
    1. You want the latest post to be displayed when somebody goes to the blog at example.com.
    – solution: set WP to show at most 1 (one) post and it does it for you out of the box.

    2. You want the comments and the comment form also displayed on the main page.
    – Solution: In the search results I gave you, hit #7 has this post:
    https://www.ads-software.com/support/topic/128143?replies=4#post-702180
    giving you the exact code:
    <?php $withcomments = TRUE; ?>
    to put it in your index.php (I tested it placing the code just below the get_header line)

    3. You want more than one post on other pages, like monthly archives, category archives etc.
    – Solution: use the CQS plugin

    Which part doesn’t work?

    I set the # of posts to 1

    I edited index.php
    – within index.php, I changed the first 2 lines to read

    <?php get_header(); ?>
    <?php $withcomments = TRUE; ?>

    I saved all changes… refreshed the site….

    And there are no comments.

    Within https://www.ads-software.com/support/topic/128143?replies=4#post-702180 there is a statement… “You include <?php comments_template(); ?> in the posts loop”

    I don’t know how to do that. I don’t know what “the posts loop” is. Is that a file? Is that a pattern in a file? Is that this?

    <div class="postdata"><span class="category"><?php the_category(', ') ?></span>  <span class="comments"><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></span></div>
    		  </div>
              <div class="entry">
                <?php the_content('Continue reading &raquo;'); ?>
    
                <p class="submeta">written by <strong><?php the_author(); ?></strong>
    			<?php
    				if(function_exists("the_tags"))
    					the_tags('\\\\ tags: ', ', ', '<br />');
    			?>
             </p>
    
              </div><!--/entry -->
            </div><!--/post -->

    Paste your whole index file to https://wordpress.pastebin.ca/ and post back with the URL

    Whenever you need some more knowledge, trust the Codex:
    The_Loop

    https://wordpress.pastebin.ca/976395
    Copy the modified code (from the input field below, NOT the numbered display!!!)

    It should work.

    Thank you. That worked for the homepage.

    I have CQS installed. I create a condition where is_archive Show -1 posts per page, ordered by date DESC. Then I click on the march archives.

    It only shows the latest post, when there are actually 5 posts in March.

    use is_month for monthly archives.

    Well folks, then my update shall be:

    file homepagepost.php in your theme:

    <?php
    /*
    Template Name: Homepage Post
    */
    
    /* display the most recent post out of any category */
    query_posts('posts_per_page=1');
    
    /* enable comments */
    $withcomments = TRUE;
    
    /* get single post template from theme */
    include ('single.php');
    ?>

    This will always display the latest post on your homepage with comments enabled. Then you do not need to code a plugin, and even better, there is no need for your authors to manage which post needs to be displayed on the homepage.

    hakre, thank you very much. This is the solution that’s best for my scenario. In addition to the reasons you mention, for each view I won’t have to manage a plugin that over rides a universal rule.

    Sometimes it is better to solve things on the level of theme then installing just more plugins. Because when you update, plugins can often run into compability issues. Some lines of own, valid code in your own theme are often more mature. At least you know where you hacked something.

Viewing 13 replies - 31 through 43 (of 43 total)
  • The topic ‘Blog Homepage?’ is closed to new replies.