That part works just fine. Using the following code in a file called “page-test-custom-template.php,” which I saved in the root folder I created for a child-theme of Twenty Twenty Three, I can assign the custom template to a page:
<?php
/**
* This is a test custom template for Twenty Twenty Three.
*
* Template Name: Test Custom Template
*
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
$title = get_the_title();
$site_name = get_bloginfo('name');
$page_title = $title . ' - ' . $site_name;
?>
<title><?php echo $page_title; ?> - </title>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<div class="wp-site-blocks">
<header class="wp-block-template-part">
<?php block_header_area(); ?>
</header>
<main class="wp-block-group">
<div class="wp-block-group has-global-padding is-layout-constrained">
<h1 class="wp-block-post-title">
<?php echo $title; ?>
</h1>
</div>
<div
style="height:32px"
aria-hidden="true"
class="wp-block-spacer"
></div>
<?php
echo do_blocks('<!-- wp:post-content {"layout":{"inherit":true}} /-->');
?>
<div class="wp-block-group has-global-padding is-layout-constrained">
<?php
echo '<p>Here is some text from PHP.</p>';
?>
</div>
<div class="wp-block-group">
<?php
$str = '<!-- wp:post-comments {"style":{"spacing":{"padding":{' .
'"top":"var(--wp--custom--spacing--medium, 6rem)"}}}} /-->';
echo do_blocks($str);
?>
</div>
</main>
<footer class="wp-block-template-part site-footer">
<?php block_footer_area(); ?>
</footer>
</div>
<?php wp_footer(); ?>
</body>
</html>
The PHP output works fine, too, so I believe I’m nearly there; however, the header and footer don’t right-justify the navigation block or the credits, respectively:
You can see the problem at the link below, and compare it to any of the other pages on the test site to see how the header and footer should look.
I’ve been wading through the CSS, and I haven’t been able to find the issue.
]]>For our website we want to create a page where people visit a cyberspace. For this to work as efficiently as possible, that one page may only run the html code we need.
But how can we stop the plugins and wp from writing on that page? We don’t need a theme there, no ads, no commerce, just raw html.
Thank you in advance.
(The page doesn’t exist yet)
]]>For some reason my page.php file is not being used by ampforwp. I’ve created a folder within my theme called ‘ampforwp’. Inside this folder I have a few page/post templates. The weird thing is that, for example, single.php does work, but for pages the file page.php is not being picked up.
When I try to use a page specific template file (for example: page-mypageslug.php), this also doesn’t work.
Am I missing something here? I read all of the documentation for this plugin, but I can’t figure out what I am missing.
I hope someone can help me with this.
]]>Thank you for a wonderful theme.
I’m new to WordPress development. I’m trying to create a custom page template for single-page.php but how to include a footer & header in it?
I want to include a footer & header & in the body, I’ll do my stuff.
I tried looking at the existing single template file, it just calls greenlet();
Kindly help me out here.
Thanks in advance
]]>I have a need to make a custom single template for the “post” post type in wordpress so my client can choose between two different single layout templates each time they create a new blog post.
I am very familar with the wordpress template hierachy and I know how to do this for a specific post using single-{post-type}-{slug}.php, however this template needs to be assigned by the client for multiple posts. I want this to function exactly like a custom page template where it can be selected in the “Template:” dropdown under Page/Post Attributes when editing the page/post.
I have created my custom template file single-alternative.php and placed the following php comment at the top of it /* Template Name: Alternative Template */ as you would do for a custom page template. This template is working correctly as it’s showing up for selection under “Page Attributes” when editing a page.
I have also added the “Post Attributes” meta box to the post edit page using the following code:
add_post_type_support( 'post', 'page-attributes' );
However for posts only the order appears and not the dropdown to select the template file.
I note that this has been asked before here:
https://www.ads-software.com/support/topic/wordpress-make-page-attribute-from-pages-and-also-for-post-pages/
I have read the response and reviewed all the links provided and they do not seem to actually answer the question. They are talking about adding custom post meta and custom fields to the Page Attributes meta box and I don’t want to add custom post meta or custom fields in this case. I just want to select the template for the single post exactly like I would for a single page. Given both pages and posts are just post types in wordpress this functionality should work similarly for both.
Lastly I understand that pages are hierarchical and posts are not by default. I believe that in order for page templates to be selected a post type needs to be hierarchical. Therefore I added the code snippet found here https://stackoverflow.com/questions/10750931/wordpress-how-to-add-hierarchy-to-posts in an attempt to make “posts” hierarchical so I could select the post template under attributes however that also did not work. Nothing new showed up under attributes, not even the parent box, so I don’t think posts became hierarchical.
Can anyone help?
Thanks very much,
Nicole
I tried <?php echo do_shortcode("[product sku="MyProductSKU"]"); ?>
, but It makes the page display the error “site currently unavailable” when you browse to the page. Any suggestions on how to display product by sku in custom page templates would be appreciated.
T.I.A
]]>TL;DR:
I’m looking for the best way to replicate the appearance of an old “static HTML” site (americanaccents.com) into a modern, data-driven WordPress site. What is the best way to do so?
The long story:
Every year, we have to update it by hand, which takes late nights, early mornings, and weekends during the last few weeks of the calendar year. Needless to say, editing a static HTML site is excruciating, but our boss wants it to look “exactly like the paper catalog.” That catalog is in a horizontal format, like a car dealership’s brochure for a new car, with glossy black pages and all. Thus, our site looks like something out of 1998.
I hate it and want to convert it to WordPress so that future updates will be as seamless as possible, with product data retrieved from a database, minimizing typos and broken links, etc. In order to please the boss, however, it needs to look as close as possible to the existing static HTML site, but with responsiveness, of course.
I have some experience with PHP and Laravel, know JavaScript well enough, and have even created an entire database from scratch that contains all of our product data, their specs, prices, etc. In fact, you can see my Laravel-driven site, which is essentially a d.b.a. of American Accents, at americancabin.com.
On that site, everything is driven by the database and displayed dynamically. It’s also responsive. (I’m honestly surprised that our stuck-in-the-past boss allowed this site to go live.) Unfortunately, the American Accents site cannot look like this. It must be identical (or close to it) to the existing AA site.
I’ve been told that this do-able and that I should use custom post types and/or custom fields. I’ve also been told to look into using Divi or Beaver Builder. I’m still relatively new to WordPress and I know I have a lot to learn, but I am certainly willing to do so, as I really want to get into the web dev industry. I even just finished watching Lynda’s course on the Advanced Custom Fields WP plugin, thinking that might also help me with this project.
Please understand that I’m not necessarily looking for someone to build it for me; I just need to know:
It would be ideal if I could also somehow import my custom-built product database into this WordPress version of the site, but I don’t expect that it would be possible. I wouldn’t mind too much recreating all of that data using WP’s tools (or plugins), though.
So, I know this was lengthy, and for that, I apologize. I tend to be thorough and a little too prolific for my own good. Anyway, is there any chance that this project could be done, and how?
]]>I have tried using my clear cache plugin and have waited hours. Nothing has changed.
It occurs to me that I might need to clear my cache in CloudFlare, but I know it will slow down my site if I clear the entire cache. If anyone knows which specific files I should clear, I would love the help.
Any ideas on how to get my template to show up? I thought I posted this earlier this morning, but it seems to have disappeared. I am not a professional coder. I’m just a novice.
Thanks in advance.
]]>