How does WordPress Dynamically Generate Pages? - php

I'm new to web building and programming and what not, but I'm trying to create a website with a lot of pages. Note that this is pages not posts. The pages will use the same layout, but the content will be different. It's very inefficient to create the pages in Wordpress. I was wondering where does Wordpress store the database that is used to generate the pages. I figured I'll just add information to the data base - which would be much for efficient.
Any ideas on how to do this? Or other ways to create many pages efficiently. I would love to be able to work with Excel or some other text software, rather than the slow Wordpress platform.
Thanks!

All content are saved to the wp_posts table in your WordPress database. whether its for pages or as posts. Databases are provided by your webhost. Edit: Excel is not a web authoring program, nor should it be used as one.

You should put your header in header.php and footer in footer.php, and main content if it's not post type in page.php or you can make you custom page template, also if you are use page and not post, don't forget change it from settings

You can't use Excel for your data. You can only use the Wordpress Database or external files.
As stated above, pages are stored in the posts table.
Since your data isn't actually dynamic, you should probably go ahead and create individual pages and create a template to display the pages the way that you want them to look.
https://developer.wordpress.org/themes/template-files-section/page-template-files/
For the record, you can use a single page to output different content. Most shopping carts, for example, are displayed using a page called 'Cart' (or something similar), but the output is different. The Events Manager plugin outputs events to a page called 'Events'. This, however, is for truly dynamic data and not what you are looking for.

Related

What is the best way to create page in Drupal 8 so that I can then add these posts with images?

I have a Home page on the Drupal website (such as is created after installation), but I still need to create this page:
What is the best way to create a page so that I can then add these posts with images?
I am just starting to learn Drupal and have heard so far about such ways of creating pages:
1) in admin toolbar: Content / Add Content / Article
2) in admin toolbar: Content / Add Content / Basic page
3) in admin toolbar: Structure / Views / Add Views
Which one should I use? Or maybe there is some other option that I don’t know about?
P.S. At the moment I am more interested how to create empty page on which I can then add posts later, and adding posts it is another question.
Welcome to Drupal.
Drupal ships with the default theme which won't look nice but it does its job in the right way. Now if you want to create a better UI/UX obviously you should create a new theme. But before that make sure to read and understand the concepts behind Drupal. Drupal docs are your first friend.
Drupal Documentation
Drupal considers everything as nodes and that's how Drupal got its power. As you mentioned, Articles, Basic Page etc are called content types and they can be used to create a particular type of content.
Now for your purpose create a new content type and add the fields you need. From the image above I can say your content type needs Title, Image, Category and Date. After creating content type you can create as many contents as you want under the content type you just created. Consider each card in your image as content.
Now you can use a Drupal Core Module Views, to perform DataBase Operations without writing single code. Yes, you can select fields, sort, order etc with Views UI and display it in a page or a part of a page (Block).
I would say just try this out in the default Drupal theme and when you understand how this works, you can start creating your own theme for your project.
Theming Drupal
There is a lot of resources available. But you have to make sure what you are asking is whether you actually need. It will take some time, but it worth.
To build layouts for homepages on Drupal 8 you best friend is https://www.drupal.org/docs/8/core/modules/layout-builder
To build the content blocks inside your home page, you should start creating nodes on a node content type to hold your information. For instance: news content type, with a title, a body, a date, and an image.
For every node type, ex. news, work on the preview display, full display, and any other display which makes sense. These displays can be used later in the Layout Builder directly or in Views, referenced below.
If you wish your list to be dynamic, such as the last 10 entries are shown first, then use a view to hold the content sorted and filtered as you need.
In a nutshell.
Create a content type for your article/news.
Modify the displays of the content types to have at least a summary and full view.
Create the content itself to have something to see.
Create the view (block) to filter and sort your content.
Create a page layout (this makes sense for landing pages) which places your new view and any other content you need in any disposition.
This is roughly what I would do. The steps described above contain many intermediate steps. If in doubt, check the docs.
I hope that helps!
First, decide what will you display on that page. Is it content in some existing content type (article maybe) or you want to crate new one for this purpose.
If you need new one then create it (Structure -> Content types -> Add content type).
Then check what fields will you need. I.e. image, some description text. Add missing ones.
Create few nodes (pages) in that type so you could work with them.
Then for displaying you should crate a view (Structure -> Views -> Add view). It can be a page view (you are displaying only that content on page) or block view (this is just a block among some others). If you create a page you could visit it and if you create a block you have to add it to some region to appear on page (Structure -> Block Layout).
Inside your theme you should create templates for this page/block. Turn on twig debug mode so it will show you hints - what templates are used and how can you name yours to override default ones.
Adjust CSS to make it look like you want it to look.
Find some tutorial(s) for the details
Previous answers have given the flow of the work you should go through, I would like to add some resource that might help you achieve this.
Creating content type and fields: https://www.drupal.org/docs/administering-a-drupal-site/managing-content-0/working-with-content-types-and-fields
https://www.drupal.org/docs/user_guide/en/structure-content-type.html
View and View modes: https://www.drupal.org/docs/user_guide/en/views-concept.html
https://www.drupal.org/docs/8/api/entity-api/display-modes-view-modes-and-form-modes
Handling block of the view: https://www.drupal.org/docs/8/core/modules/block/overview
Feel free to ask if any further explanation is needed.
Thank you

populate Wordpress page/post from external db - on the fly

After providing an event calender with PHP/MySQL/HTML/CSS I want to use Wordpress for that project from now on. Account and data management will remain outside of wordpress scope.
My best idea so far is to populate the posts (or pages) entirely from the already existing db. The URLs would be created by apache's rewrite engine.
To use one post and populate just the content would lead to really bad SEO.
So I want to create (virtually) unique posts populated entirely from the db. Extensive research on that topic brought up nothing usable so far. Maybe someone could point me in the right direction?
Preferences:
using mod rewrite to create the pages urls from event /ID/title rather than using the timestamps to create posts
keeping the data editable via external admin panel (no copying into WP-DB)
head data of post / page must be populated from db, e.g. title, author, timestamp etc.
Suggestions would be much appreciated, thanks in advance.
Have you tried the plugin WP All import. It creates unique post such are car listing etc based on the external DB. I also allows you to style and format your post.
https://wordpress.org/plugins/wp-all-import/

WordPress multiple content sections

Alright I am completely lost on how to do this so I am just going to throw the question out there and hope somebody can help me in some way or another.
WordPress offers the option to create custom Taxonomies so I got the idea of pulling something out of my hat and creating a custom content section apart from the content section wordpress currently offers.
The website shown above is the only website I have been able to find which currently does this and is on a WordPress platform, as you can see they have the SoundCloud audio player pushed over to one side with the actual content placed to the other side creating that flawless look.
I guess the question here is how can I turn <?php the_content(); ?> into something completely custom pulling from a completely different form in the back end so the same information is not shared.
There are numerous ways to achieve what you want.
Shortcodes
Custom page templates
Custom meta fields to store values like the soundcloud embed url, to afterwards use it in your code.
You can always also enter HTML in the page editor, but for obvious reasons not recommended.
Custom post types allow you to define a new type of content. It will have its own section in admin where you add and edit data separate from normal Wordpress posts. It can have its own templates allowing different layouts, and you can set up custom fields so that it can store different data.
I also recommend taking a look at the Pods Framework. This plugin allows you to define custom content types very easily in the admin interface. You can set up all your fields and data types from there. All that's required then is to create the templates to make it look nice.
The nice thing about these approaches is that while the data is kept separate from standard Wordpress posts, you still have the same familiar UI, so it's easy for none-technical users to update the content.

Calling active wp_posts row

Is it possible to echo a value from the active post in wordpress?
Example: If I make a row called: post_numberofreads and I want to echo this value for each post, by inserting a line of code in the single post template page (single.php) that calls any given posts 'post_numberofreads'. How would I go about doing this?
Please notice that this is an example. The important part is that I want to echo something from the active row - not just get the number of reads.
Thanks for your time.
While the ideal solution is to create a wordpress plugin with your custom functionalities but it require good understanding of wordpress and plugin development.
The other solution more can be to inject your custom code in the wordpress core manually. I is comparatbiliy easy and often unsecure and get broke frequently.
For second option you can:
A) Create required custom columns in wp-posts in wordpress database using phpmyadmin or your favourite tool.
B) Inject your code into the relevant files. Generally these files are:
wp-content/themes/your_theme/single.php #For blog post
wp-content/themes/your_theme/page.php #For pages
C) Then you can using built in wordpress functions like get_the_ID to get current post ID. You can also other wordpress functions to communicate with wordpress database or write your own functions.

Pull content from a remote WordPress install

I need to create a wp widget that automatically pulls data from another wordpress install on a remote server.
Basically, the source site is a review site where offers vary over time. My widget will pull certain offers and make sure they stay updated.
Reviews on the source site are custom post types with custom meta fields that need to be fetched (price, offer, etc).
Looking around I've seen different suggestions: query the remote db, fetch the feed (does it store custom meta fields?), use json (which I barely know what is, but I am willing to learn new stuff).
What is the best method for my purpose and where can I find resources to help me achieving my goal?
Thanks for your help!
WordPress allows you to have an RSS feed per custom post type which is handy. Then you can make use of the WordPress Fetch Feed function to scoop what you need!
Are you the creator of the remote website?
You can create a new template in your theme
Code what you want to display in the format you want to display it
(json or just a bit of html)
In your wordpress admin create a new page and assign the new template
to it.
In your new site you just have to fetch the page

Categories