1. Home
  2. ReHub Theme
  3. Advanced tips and customizations
  4. Adding custom Post layouts

Adding custom Post layouts

One of big advantages of our theme is that Rehub has many ready Post layouts which can change your regular post view to e-commerce style, price comparison style, review style and much more. Read about this

You can also add own custom post layouts with next steps.

First of all, register your post layout in select box. For example, you want to register layout with name “My custom post layout” and key “custom_one”.

Use next code in functions.php

add_filter('rehub_post_layout_array', 'mycustom_layout_for_rehub');
function mycustom_layout_for_rehub() {
$custom_post_layout = array(
array(
'value' => 'default',
'label' => __('Simple', 'rehub_framework'),
),
array(
'value' => 'meta_outside',
'label' => __('Title is outside content', 'rehub_framework'),
),
array(
'value' => 'meta_center',
'label' => __('Center aligned (Rething style)', 'rehub_framework'),
), 
array(
'value' => 'meta_compact',
'label' => __('Compact (Recash style)', 'rehub_framework'),
),
array(
'value' => 'meta_compact_dir',
'label' => __('Compact (Redirect style)', 'rehub_framework'),
), 
array(
'value' => 'corner_offer',
'label' => __('Button in corner (Repick style)', 'rehub_framework'),
), 
array(
'value' => 'meta_in_image',
'label' => __('Title Inside image', 'rehub_framework'),
), 
array(
'value' => 'meta_in_imagefull',
'label' => __('Title Inside full image', 'rehub_framework'),
),
array(
'value' => 'big_post_offer',
'label' => __('Big post offer block in top', 'rehub_framework'),
), 
array(
'value' => 'offer_and_review',
'label' => __('Offer and review score', 'rehub_framework'),
), 
array(
'value' => 'meta_ce_compare',
'label' => __('Price comparison (Content Egg or Multioffer)', 'rehub_framework'),
),

array(
'value' => 'custom_one',
'label' => __('My custom post layout', 'rehub_framework'),
),
);
return $custom_post_layout;

}

As you see, you have all layouts in array (so, you can delete some if you don’t need them) and we add our layout in end

Now, you need to customize single page template to show your layout

Copy file single.php from main theme and insert it in your child theme or grandchild plugin.

Find lines

<?php else:?>
    <?php include(rh_locate_template('inc/post_layout/single-default.php')); ?>

insert before this line

<?php elseif($rh_post_layout_style == 'custom_one') : ?>
    <?php include(rh_locate_template('inc/post_layout/custom_one.php')); ?>

Now, last step, you need to create template for your layout. Copy one of templates from folder inc/post_layout. Rename it to custom_one.php and place in folder inc/post_layout (you must create it) inside child theme or grand child plugin.

Here details about using child themes and grandchild plugin

 

Was this article helpful to you? Yes No

How can we help?