In the functions.php, I have the following code added:
add_post_type_support( 'page', 'excerpt' );
This allows pages to have excerpts. The reason I want an excerpt is because I want to call only pages with excerpts to be one of 3 modules on the home page.
On the front page, in my home.php file, these 3 modules will show the titles and excerpts of the pages in which I have added an excerpt. At anytime, the editor should be allowed to change the placement or page so that any existing page could theoretically become a module on the home page.
For example, I have an About, New Patients and Services page, all three of which I have added text to the excerpt field (I will leave all other excerpt fields blank on pages which don't need to appear on the front page). On home.php, in the order I just listed, I want the title and excerpt of each page to show up as three columns.
Here's how I intend to style it: https://i.sstatic.net/jOPb0.png
It's possible these 3 modules will either need an order change or replaced by another page, which is why I'm looking for dynamic modules.
I have created two custom fields, called home_widget
and order
. home_widget
is equal to either true
, whereas order
is equal to the order they should appear on the page.
This code is wrong, but I'm looking for similar logic:
<?php
$pageExcerpt = get_the_excerpt();
if (is_page() && $pageExcerpt !== '') {
the_excerpt();
}
?>
In other words, if a page exists AND it has an excerpt, then call the_excerpt() but do it in the order I define by custom field entry. This allows for dynamic insertion as needed.
How do I write this code to work as I stated?