How to create a custom page template in "Beans"

I want to create a custom page temaplate in "Beans" ... I have created a file in the root of the Beans child the directory with the name "full_width.php" ... and put the following code there ...

Template Name: Full Width

// Load beans document

Now when I create a page selecting the "Full Width" template and browse that page ... I don't see any postes ... But the header, sidebars and footer is perfectly publishing ... I mean the post loop is not showing up ... What should I do to publish the loop and the manipulate it here using beans hooks n APIs ... Thanks in advance

Hello @codefactory,

What do you want to do exactly ?

Do you want to create 1) a specific layout to display posts (say, posts from a given category or tag) ? Or do you want to 2) change the appearance/layout of a page ?

If the answer is 1), then the best thing to do is to create an archive template. For instance, let's assume that you want to display posts of a category called "dogs" in a grid layout. The first thing that you'll want to do is to is to create a specific template category-dogs.php.

Then, in this file, you can add this, for instance :

// Add grid.
beans_wrap_inner_markup( 'beans_content', 'beans_child_posts_grid', 'div', array(
'class' => 'uk-grid uk-grid-match',
'data-uk-grid-margin' => ''
) );
beans_wrap_markup( 'beans_post', 'beans_child_post_grid_column', 'div', array(
'class' => 'uk-width-large-1-3 uk-width-medium-1-2'
) );

// Move the posts pagination after the new grid markup.
beans_modify_action_hook( 'beans_posts_pagination', 'beans_child_posts_grid_after_markup' );

Once again, this is just an example.

If the answer is 2), then, in the page template that you have created, ie full_width.php, you can add all the modifications that you want. Theses modifications will be applied to the page you've choosen by selecting the page template in the WordPress editor.

In you case, it is full_width.php. Let's say that you'd want to have a bigger title in this page. In this file, just add, for example :

// Add Class to title.
beans_add_attribute( 'beans_post_title', 'class', 'uk-heading-large' );

I can't encourage you enough to have a good read of the Codex...

Have a nice day !


Write a reply

Login or register to write a reply, it's free!