Tag Info

New answers tagged

0

A page template for every Custom Post Type is NOT a bad practice. What is a bad practice however is using a custom post type to do something that a good category structure could have done. "Efficient and effective ways to do such things" depends on what "such things" are; there is no 'one-size-fits-all'. We'd need more detail on your particular situation to ...


0

You need to add a new row before the loop. <div class="row-fluid"> <div class="span12">Your title here</div> </div> <div class="row-fluid"> <div class="span6"> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'page' ); ?> ...


1

One way is to have a single front-page.php and then using get_template_part(), to show different content based on user choice. Rough code: get_header(); $layout = get_option( 'front_page_layout', 'default' ); get_template_part( 'front-page', $layout ); get_footer(); After that you need to create a file for every layout, they should be called, something ...


1

function get_custom_post_type_template($single_template) { global $post; if ($post->post_type == 'events') { $single_template = dirname( __FILE__ ) . '/single-event.php'; } return $single_template; } add_filter( 'single_template', 'get_custom_post_type_template' ); Source Or you could use: add_filter( ...


0

There is only one option, the page templates one. This is how 99% of the themes work and what wordpress users and implementators are used to. You can try to be unique but no one will appreciate it.


1

This is what I've always done. Not sure if you need both $wp_query and $post but it's always worked for me. Just put this in plugin-main-file.php /** * Add single template for events post type plugin */ function custom_template_events_post_type_plugin($single) { global $wp_query, $post; if ($post->post_type == "events"){ $template ...


1

According to the Codex, your custom page template must have a header containing the name of the template. All page templates must be named in this way, or they will not appear in the "Template" dropdown. Here's an example, make sure your custom template has a header in this format: <?php /* Template Name: My Custom Page */ // Your custom page template ...


2

May be something is wrong on your page template file. Have your added page template name at top of the page like this: <?php /* Template Name: My Custom Page */ Try with this and check once again. You can check WordPress document for creating custom page template. Check this link: Page Templates


1

Instead of having a page template for all of them, have a single page template and use get_template_part to pull in the parts unique to each page. So instead of: update_post_meta($new_page_id, '_wp_page_template', $page_filename); You'd have: update_post_meta( $new_page_id, '_wp_page_template', 'newpagetemplate.php' ); update_post_meta( $new_page_id, ...


0

You can tie it to the 'wp_head' hook. http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head


0

What about admin_init ? Description is: admin_init is triggered before any other hook when a user accesses the admin area. This hook doesn't provide any parameters, so it can only be used to callback a specified function.


0

You can set the display status with show_admin_bar function <?php show_admin_bar( false ); ?>


0

It is kind of hackish but I found adding the below snippet inline just like WordPress core did the trick. I hate inline styles but life doesn't always produce lemonade :-S /** * Hides the admin bar on a template page. */ function hide_admin_bar() { wp_add_inline_style('admin-bar', '<style> html { margin-top: 0 !important; } </style>'); ...


1

I think your big problem here is your use of underscores (_) in your page template names. According to the Handbook of Coding Standards Files should be named descriptively using lowercase letters. Hyphens should separate words. my-plugin-name.php Also, for best practices you should call your custom page templates page-whatever.php So for ...


1

It seems the problem was it wasn't recognizing it was a page in the first place and thus couldn't recognize if there was a template applied to it. Changed if (is_page_template('page-templates/page-nosidebar.php')) { to if (is_page() && !is_page_template('page-templates/page-nosidebar.php')) {


0

There are a few problems with your code which I will take you through. PROBLEM 1 Whether you are using wp_enqueue_style() wp_enqueue_script() wp_register_style() wp_register_script(), they all have the first parameter in common, $handle. This is $handle (string) (required) Name of the stylesheet (which should be unique as it is used to ...


3

Your problem is that you didn't wrap it in a callback, but executed it immediately when functions.php was loaded by core. By then the global $wp_query object isn't initialized fully and the is_category() etc. wrappers can't deliver what you are expecting them to do. So your if/else checks should be moved inside the callback like this: add_filter( ...


1

A couple issues here... First, the init hook is too early for WordPress to know which page template you're going to be using. (So the is_page_template() function will always return false). Just go ahead and hook your function to wp_enqueue_scripts (which you're probably already doing for your global CSS / JavaScript). And then check for the page template ...


1

If you want all of the visual aspects of the second theme on that one page, you could do something like this. It's hacky and I wouldn't recommend doing this but it's your question! From where you say you're at now (separate header/footer/page.php) you simply need to update the URLs that call in the CSS and other support files. These may include a "pieces, ...



Top 50 recent answers are included