Skip to content

Instantly share code, notes, and snippets.

@thecodepoetry
Last active March 22, 2018 21:06
Show Gist options
  • Save thecodepoetry/9ceced7f7dff0501c01c to your computer and use it in GitHub Desktop.
Save thecodepoetry/9ceced7f7dff0501c01c to your computer and use it in GitHub Desktop.
Dynamic page layout management
add_action( 'get_header', 'dt_archive_layout', 10 );
function dt_archive_layout() {
$config = Presscore_Config::get_instance();
if( is_archive() || is_category() || is_search() ){
$config->set( 'template.columns.number', '5' );
$config->set( 'post.preview.width.min', '200' );
$config->set( 'image_layout', 'resize' );
$config->set( 'thumb_proportions', array( "width" => "2", "height" => "1" ) );
}
}
@thecodepoetry
Copy link
Author

Try this cod in your child theme functions.php to change layout of archive, category number of columns.

To get the exact same settings of you blog listing page, try to print the config vales in the original template you are using and apply to the dynamic page like shown above.

to print the values edit the template, after line

presscore_config_base_init();

add these (temporary, remove once you get the configs)

echo '<pre>';
print_r($config);
echo '</pre>';

PS: making these will print large amount Raw script on site and doing this directly on a live site is not suggested, If you are not comfortable with coding please get help of a developer.

@nacm
Copy link

nacm commented Jun 16, 2017

This is very helpful. Thanks

@Mediadom
Copy link

Hi,

I search on wich file i can put
echo '<pre>'; print_r($config); echo '</pre>';

after

presscore_config_base_init();

Thx :)

@TooLogic
Copy link

Hi,
Can I create separate archive layout for teammate posts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment