WordPress is fetching current post for you, you have to only type to the right url. When you get e.g. to example.com/lorem-ipsum/
WordPress will load automatically post with title Lorem ipsum
and display it using page.php
template. Your page.php
template should be looking something like that.
<?php get_header(); ?>
<div id="content">
<?php while ( have_posts() ) : the_post(): ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; ?>
</div>
<?php
get_sidebar();
get_footer();
The concept of a loop is difficult to understand for novice developers. Only in the loop you can use functions like the_title
orthe_content
. Outside of the loop
, these functions won’t return you anything.
Related Posts:
- How to auto login user again after change user_login
- How to Join two tables from separate databases within WordPress
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- WPDB: how to get the value of a field in a custom database table
- phpMyAdmin displays error when importing database
- Transferring working local PHP site to wordpress – with database (MySQL)
- Databases – Submitting data from inputs to database [closed]
- Is it best to avoid using $wpdb for security issues?
- Lost in trying to create user database system
- Filter results from a serialized string to use on statistics
- wordpress site – using custom database and PHP
- add role on WordPress in PHP on a second database
- Front end/Database connection in WP
- direct query to post_meta table
- can’t delete a row from post_meta table
- Can not manually create a database ( db, user, pass ) for a plugin
- Querying multiple meta_keys in WordPress SQL query
- Retrieve data from external database and insert back in
- Split reads to a different connection string
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- Execute long and heavy processes
- Dynamic content in template
- database sent to a JSON file
- Archive post by meta value + 24hours
- inserting a post from an extern php file but post content doesn’t show on wp site
- Genesis framework comments broken?
- $wpdb->insert() does not Insert record in a table
- Using custom tables for old posts
- db converts decimal number wrong
- Not connecting to database in file with multiple MySQL connections
- Filtering a Database Query
- Display Data in Table from External Database in WP using Shortcodes
- How can I import an excel column into wordpress database?
- Blob file download problem
- WordPress Block developer from exporting Database via PHP
- How to retrieve the data from the sever and displaying it in a page?
- Execute a function every hour in the background
- Create page with custom php script and fetched data
- wpdb prepare insert table doesn’t work
- Should I use WordPress to skin a database website?
- How do I display offsite database info on my wordpress site?
- Creating Database Table vs. Adding MetaData to Post & User
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- dynamic page using php from sql database
- Building a REST API for your web app exposes primary keys of DB records?
- Most commented posts by time period (last 12h, last 24h and etc)
- Use $wpdb or other PHP script method to find/replace in WP database
- How to Update post_modified of all wordpress post
- Correct PHP to output a single result of a Function with SQL Query
- How can I add a new row in a separate database when someone registers via WordPress?
- Saving data from custom form in wordpress database
- How can I find the cause of a 500 server error?
- I can’t update my data through $wpdb
- wpdb Cannot Update column in Database
- Can’t successfully check if post with title exist in database
- Cant connect to database with php 7.3
- PHP -> SQL Query with Summing
- Delete database record using plugin from admin panel
- Pull MySQL data from multiple tables and merge into 1 PHP array
- How to get image from url from the database?
- Set default Database Storage Engine when creating tables with plugins?
- Wpdb get->results to out the the month from the db
- How to add data to a custom field at the wp_users table?
- Creating custom page template from existing PHP site
- Searching Posts Programmatically in a WordPress Plugin
- Get wp_current_user_id using PHP and MySQL
- Use variable in SQL statement
- WPDB – Read and write value from / to database
- How do I make this Metabox show current DB value?
- Why my query does not run with prepare
- How to Generate a list of Most Commented post?
- Why when I create a new post I found 2 record related to this post into the posts database table?
- Adding data to custom wordpress database table
- wpdb getting avatars and author url
- mySQL queries are executed twice on wordpress website
- phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- Add row to custom database Table and delete all rows older than 1 day
- select a single val though a table in wordpress
- making php value numeric
- Using color schemes with Color Picker
- WordPress SQL JOIN query
- Fetching review value using wpdb class
- Remove password protection from all posts
- quotes problem in very simple sql
- wordpress sql posts query won’t display the latest post in a specific category
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- SQL error with custom query
- WP_Query: How to get results from both meta_key options?
- Unserialize Custom Field & Save as Multiple Rows in WordPress Database
- Add posts to custom table in database instead of wp_posts
- get_terms with specific id order
- What’s wrong in my PHP code? I’m using WordPress Astra Theme and I can’t insert data into my SQL
- Using PHP Code Snippets to query a database, $dbconnection->get_results is outputting nothing
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- Database entry removed on browser refresh, Ajax PHP jQuery
- Database SQL query error
- get different meta-data of a complicated query at the same time
- WordPress SQL Prepare
- Please help! I have a problem with getting wordpress databas
- Change wordpress’ database data using ajax – how to get current user id?