Layouts plugin provides a drag-and-drop editor that is used from the WordPress administration. Using this editor, you can create layouts, assign them to specific content and design entire pages.
When you ask for help or report issues, make sure to tell us the design that you want to achieve and the layouts that you have created so far.
Viewing 15 topics - 196 through 210 (of 214 total)
Problem: I would like to apply a different Layout to my custom taxonomy archives depending on the hierarchical level of the term.
Solution: Use custom code to programmatically select a specific Layout for each hierarchical level:
function apply_layout_by_archive_term_hierarchy( $id, $layout ){
// all the taxonomy slugs that should use these hierarchical layouts
$taxonomies = array( 'your-custom-taxonomy' );
// the layout IDs for each level of hierarchy, separated by a comma
$layouts = array( 123, 456, 456, 789 );
// ---------------------------------------------------
// you should not edit anything below
// ---------------------------------------------------
$layout_to_apply = $id;
$current_taxonomy = isset(get_queried_object()->taxonomy) ? get_queried_object()->taxonomy : null;
// test for the correct taxonomy archive
if( !$current_taxonomy || !in_array( $current_taxonomy, $taxonomies) )
return $layout_to_apply;
// find the hierarchical term level and apply the corresponding layout
$current_term_level = get_tax_level(get_queried_object()->term_id, $current_taxonomy);
if( isset( $layouts[$current_term_level])){
return $layouts[$current_term_level];
}
// fallback to original layout
return $layout_to_apply;
}
add_filter('get_layout_id_for_render', 'apply_layout_by_archive_term_hierarchy', 10, 2);
function get_tax_level($id, $tax){
$ancestors = get_ancestors($id, $tax);
return count($ancestors);
}
Problem: I would like to use a custom shortcode to display some custom pagination links, but when I try to echo the code in PHP it is displayed in the wrong place on the page.
Solution: Check the documentation for the Shortcode API. It's best practice to build a string with concatenation, then return that string. Echo should not be used in a shortcode.