WordPress.org

Ready to get started?Download WordPress

Forums

Create post individually and then display post individually by name (5 posts)

  1. xtremeordeal
    Member
    Posted 1 year ago #

    Hello I need to create individual post. Then I need to call those posts by the name I just made them. I've looked everywhere and tried literally every thing on Google and nothing has worked yet.

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    This is achieved by enabling Permalinks with the setting of /%postname%/

    Once set, rewrite rules are created in the .htaccess file found in the root of your WP installation.

    At this point, the url for a post titled "My New Post" will be //yoursite.com/my-new-post/

  3. xtremeordeal
    Member
    Posted 1 year ago #

    I'm trying to do this in the functions.php file and index.php
    This will be programmed into my theme. So then when someone installs my theme the post I created in the code will already be there and ready to go.

  4. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    Above is core WP functionality and does not need to be edited in either of those files...

  5. xtremeordeal
    Member
    Posted 1 year ago #

    I don't think you understand. This is what I had so far.

    <?php // Create post object
    $my_post = array(
         'post_title' => 'How to make your diet success',
         'post_name' => '7-ways-to-make-succes-Diet',
         'post_content' => 'my content',
         'post_status' => 'publish',
         'post_author' => 1,
         'post_category' => array(8,39)
      );
    
    // Insert the post into the database
    wp_insert_post( $my_post ); ?>

    Then I need a way to display this post on index.php

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags