New answers tagged

-4

From version 3.1.0, WordPress decided to add a toolbar for logged in users on the display side that's about the site's theme. And add default admin bar callback before </head>: <style type="text/css" media="screen"> html { margin-top: 32px !important; } * html body { margin-top: 32px !important; } @media screen and ( max-width: ...


0

Custom post type can have template options like Pages, but its little complex, but i will try to explain it: 1) you need to register a new meta box with a drop down (custom meta field) of all the templates: function register_post_cookingrecipes() { add_meta_box('cookingrecipes-details', __('Template Details'), 'add_cookingrecipes_meta_box', '...


0

This is not possible at all. There aren't even duplication between page templates between the bundled themes. There is no way for you to know or to predict functions, outlay or markup in any template. IMHO, because of this, templates should always reside within a theme and not in a plugin. Afterall, templates are theme specific and not compatibable cross ...


1

This is a little old but you can also try this: Create a template for the custom post type: single-*custom-post-type-slug*.php The file should check the slug and verify if a file exists, if not, fallback to a default template file: <?php $slug = get_post_field( 'post_name', get_post() ); $slug = ( locate_template( 'templates/*custom-post-...


0

Unless you have generated metafields called 'home', 'about', 'contact' and 'services' in functions.php using add_post_meta your calls to get_post_meta will always return false. So if you test if they are true later on, the answer is 'no' and nothing will be displayed.


0

I figured it out. Thanks to an answer posted here. The code is $term_slug = get_query_var( 'term' ); $query_args = array( 'taxonomy' => 'news_category', 'term' => $term_slug, 'post_type' => 'news' );


0

Using template_include (as suggested by Brad Dalton) only changes the page template on the front end, not in the admin when editing a page. On the other hand, changing the value in the post object before the metabox is rendered, as suggested by czerspalace, works! I added a check to only apply this when $post->page_template is not set, like this: ...


0

Answering my own question here, for anyone who might encounter this problem in the future. The cause for the right templates not loading was having uppercase letters in my template filename. Changing all characters in the filename to lowercase resolved the problem, and the templates are now being applied as they should. I'm still unsure about what is the ...


0

Use the get_search_form filter: add_filter('wp_nav_menu_items','add_search_box_to_menu', 10, 2); function add_search_box_to_menu( $items, $args ) { if( $args->theme_location == 'primary' ) return $items. get_search_form(); return $items; } add_filter( 'get_search_form', 'custom_search_form' ); function custom_search_form( $form ) { ...



Top 50 recent answers are included