Hey folks. I'm just learning the basics here - Watched through some of Chris' excellent tutorials and am starting to experiment with layouts. I've got questions on the basics - things that I couldn't find imediate answers for in the Docs, so thought I could ask them in one thread as I go - maybe other beginners would find the replies useful as well.
Q.1 - Custom Layouts: Following on from https://goo.gl/QxtSeR which explains how to create Layouts based on Post Type, Category etc.. What if I want to create a custom template name that shows up in the WP Admin dropdown? Should it not look like this..
<?php
/*
Template Name: Test Page Layout
*/
....modifications...
beans_load_document();
Seems like I'm doing something wrong.
That's basically it - you just created a page template which you can select when editing a page on WP Admin. If you wanted to create a post type-specific template, you'd have to name the file single-{post_type}.php
and get rid of the Template Name: Test Page Layout
part. (See https://codex.wordpress.org/Post_Type_Templates.)
On the page you referenced, those hooks beans_header_after_markup
and beans_content_prepend_markup
are places in a Beans theme where you can insert / manipulate / remove content and such.
Running with the example you gave, here's your template with some said hooks in action.
<?php
/*
Template Name: Test Page Layout
*/
// some text just after content
add_action( 'beans_content_append_markup', 'template_stuff' );
function template_stuff() {
?>
<div class="uk-text-center uk-margin-top">
<span class="uk-h1">something after content is displayed</span>
</div>
<?php
}
beans_load_document();
To see more Beans hooks, enable developer mode (from WP Admin, Appearance -> Settings) then go to the front and and open your console. Browse through the markup, you'll see parts that look like data-markup-id="beans_content_append_markup"
. Those are all places that you can manipulate using Beans.
Thats great - thenks Kevin. Works fine. No idea why mine wasn't working!