New answers tagged

0

As our attempts to help don't seem to have worked, I've taken your code as the question currently shows: <?php /* Template Name: Trends */ get_header(); ?> <section id="top"> <?php the_post(); ?> <div class="intro"><?= get_the_title(); ?></div> <?php the_content();?> <?php $args = array( ...


0

What I see is , you are not following WP coding standard. <?= get_the_title(); ?> is not allowed in WP coding standard. Now you are getting only the post and not as per your args provided, this means you have not reset your main WP Query. We can write the above code as : <?php /* Template Name: Trends */ get_header(); ?> // Primary loop ...


-1

Had a similar problem - from what I've read on Timely site, widget is only designed for use on external sites and causes conflicts on pages also displaying the calendar. Shame, but can't see a workaround.


-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

It is normal to have some text used in template. Typically that would be pieces of "technical" text, related to interface and which must be in code to be localized. In solutions meant for public use it is certainly not normal practice to have actual content hardcoded in templates. For private projects it is more or less — do what makes sense to you. One ...


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 ...


0

Ok as mmm has pointed out that I can't do the dropdown select of templates on custom post types I have put this code in my single-cpt.php global $post; if ( ( $post->post_type == 'location' ) && has_term( 'news', 'highlights' ) ) { include('templates/template_feature_highlight_layout.php'); }


0

You could put files in wordpress/wp-content/themes and then include them from various themes. You could even make a folder named wordpress/wp-content/themes/global-includes or shared. For me, including a file from the parent directory I couldn't just do: <?php include_once "../globalform.php"; ?> Instead I needed to do: <?php include_once ...


1

Assuming it is a page template that is not set to Blog Posts Page: Using pre_get_posts to show only one category doesn't work as the main query contains only page content and is not a post loop. So we can do this using a secondary query using WP_Query. Look at WP_Query category parameters <?php $args = new WP_Query( array( 'cat' => "YOUR CATEGORY ...


0

<? // Check: // 1. If you are editing post, CPT, or page // 2. If post type IS NOT SET if( 'post.php' == basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']) && !isset($_GET['post_type']) ) { // get post ID $postid = $_GET['post']; // check the template file name if ('my_template.php' == get_page_template_slug($...


0

"available only when user choose this template" ? I'm not sure (I doubt it) if this is even possible. Instead I would suggest either of the following two options: If you want to make the page template configurable on a per-page basis then meta boxes could be the right direction. You could for example add an option like "use featured image as background" or ...


0

The single_template filter will let you use whatever template file you want for your CPT, but it's up to you to provide some means of selection and storage of a template name or some other reference to make it a dynamic solution. The built-in page post type does this by reading all of the valid template files in your theme, and adding that list to a meta ...


1

From what I understand, you've got two options. Option 1: Dynamic Solution Create categories for your custom post type - each category is going to have its own template. You then create a single template that splits off based on category. Meaning you use the general header and footer in your single-postypename.php and anything else that you want to apply ...


0

You could consider using the page templates. For the example im going to use a contact page. "contact-page.php" You can then write in the code you need for the template. To keep the flexibility look up how to use the Customizer (if you're not familiar with it) and use this in the template page to let the admin modify the page content without having to look ...


0

While shortcodes by themselves are linked to functions, I think you could use them effectively in combination with templates and a metabox for their input data. eg: add_shortcode('content-box','content_box_function'); function content_box_function() { global $post; $title = get_post_meta($post->ID,'_content_box_title',true); $content = ...


3

You can always make use of the page_template filter to tell WordPress to use a specific page template for all child pages of a certain parent. It is as easy as creating a special page template, lets call it page-wpse-person.php. Now it is as easy as including that template whenever a child page of people is being viewed. For the sake of example, lets say ...


2

The easiest way would be to create a custom post type 'person', in which you include the custom fields. The WordPress template hierarchy would then ensure that the single-person.php template is used for those posts.


2

This is an interesting question, though a bit too broad for a Q&A model. Here is what I would do: Create a custom post type, where each post is a block of content Create a second custom post type for pages that are assembled from blocks of code. In stead of a content field, create ten drop down fields (or more if there are more blocks possible on a ...



Top 50 recent answers are included