New answers tagged

0

the last $file takes priority over the previous That's because you assign the new value to the $file variable at every line. The only way I see you can do it by using the array: <?php // define directory list $directories = array( 'home', 'pages', 'blog', 'single-posts', 'products', 'templates', 'products' ); // run ...


0

That looks like a http://para.llel.us/support/ theme. You might start there for docs—for instance, they probably have a custom 'Theme Options' page in the admin. Short of that, and presuming you're ok with setting it in code (which may negate any future settings in the admin), you'll first need to find out where $blog_query is being defined. You can start ...


-1

Use the following code: query_posts('posts_per_page=5'); $blogOptions = ($shortcode_values) ? $shortcode_values : $theLayout['blog'];


0

You can have the choice to display full content or excerpt by adding a custom field named "full-post-display" and then add following loop in your theme file: <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $customdisplay = get_post_custom_values("full-post-display"); ?> <?php if (isset($customdisplay[0])) { ?> ...


4

Style.css contains File Headers which are needed to outline basic information about your Theme. The index.php file is meant to be the primary fallback file for your theme. It's the "there are no other templates available to display for these pages, so we will end up at index.php. Here's a diagram: In short, these two files are the minimum required files ...


0

I believe you can do something like this (not tested): if($_SERVER['REMOTE_ADDR']=="89.0.0.0" && $post->ID==15){ $post5 = get_post('5'); echo $post5->post_title; //Call custom meta using $post5->ID; } Update: If you'd like to replace the original object you can do the following: if($_SERVER['REMOTE_ADDR']=="89.0.0.0" && ...


0

I did this in the end: global $post; if ( isset( $post ) ) { $pagetemplate = get_post_meta( $post->ID, '_wp_page_template', true ); if ( !empty( $pagetemplate ) ) { if ( $pagetemplate == 'page-landing_child.php' ) { //do something } } }


4

I'm not sure if this is for front end or back end, so I'm going to handle both. BACK END You can make use of get_current_screen() or the $pagenow global. Here are two examples which you can add in a plugin or in your functions.php to check the relevant info on an admin page add_action( 'current_screen', function ( $current_screen ) { ...


0

Okey, the problem is now solved. I had used both the parameters 'loop' and 'page' for the get_template_part function in the custom template's content php code. I removed the 'loop' parameter and ... voila , it works fine now.


0

Create child theme of the main theme you're using. That way you can override just the parts you want. Reference - https://codex.wordpress.org/Child_Themes Hope it helps!


0

You can use the theme_page_templates filter to inject your page template. For example: add_filter( 'theme_page_templates', 'filter_inject_page_templates' ); filter_inject_page_templates( $templates ) { $path = 'path/to/the/template/relative/to/the/theme/folder'; $templates[ $path ] = 'Name of the template that displays in dropdown; ...


0

Divi will not be able to support all of the features as you've stated out of the box. With integration of things such as WooCommerce which Divi prefers you use, you'll be able to incorporate features like the quote but probably not on the product comparisons. That being said, DIVI is a very powerful theme, but keep in mind that many themes will need ...


0

There is no straight forward way to this, as per my knowledge. I have tried to search as well, and did not find any better solution than the below one. Below codes will provide you exactly what you are looking for: class PageTemplater { /** * A Unique Identifier */ protected $plugin_slug; /** * A reference to an instance of ...


0

You will need to read the taxonomy template article on WordPress.org for that information.


0

Why you are changing the code for these thing which are able done via dashboard.? WordPress comes with a built-in feature that allows you to instruct search engines not to index your site. All you need to do is visit Settings » Reading and check the box next to Search Engine Visibility option. When this box is checked, WordPress adds this line to your ...


0

there is no need to handle the pagination like this: $paged = get_query_var( 'paged', 1 ); Just put this after the loop: get_the_posts_pagination( 'mid_size' => 1, 'prev_text' => '&nbsp;', 'next_text' => '&nbsp;', 'screen_reader_text' => 'A' ) like this: if( have_posts() ){ ...


0

So it took me nearly 3 days to figure out what was wrong but I narrowed it down after a very exhaustive set of tests. I figured I'd post the answer for my own reference and if, for any reason, someone made the same mistake as I did. The question I kept asking was "What is different between these two posts?". The answer I failed to keep giving myself was ...


2

Your research lead you to the correct answer. Internationalization (A.K.A i18n) is best practice and is not as complicated as it may seem. You'll be better off in the long run learning it now. @Pieter Goosen is 100% correct with his advise in response to your suggestion using variables and constants. Keep out of global scope (creating globals and ...


0

Filter template_include, use output buffering to catch the rendered file content and DOMDocument to change it. Untested example: add_filter( 'template_include', function( $template ) { // Bail out early. if ( 'the-file-you-want-to-filter' !== $template ) return $template; get_header(); ob_start(); include $template; ...


0

I'm not sure you can - if you can't make a child of a child theme ( which I'm fairly certain you can't ) and the main theme doesn't supply any hooks - the only real thing you could do is hook into get_footer(); but that may be too late.


0

As of WordPress 3.4 you can put your page templates in whatever direct subdirectory you need, it doesn't sound like you can put them into sub-sub directories but I haven't tested this. I suggest storing templates into /page-templates/ folder as WordPress seems to recognize it. From WordPress Page Templates Entry: WordPress recognizes the subfolder ...


1

Custom post types are by default excluded from the main query except on taxonomy pages and custom post type archives. You can simply use pre_get_posts to correctly alter the main query (alter the query variables before the SQL query is build and executed) to your needs. Just a few notes on pre_get_posts pre_get_posts runs front end and back end queries, ...


0

You need to use taxonomy.php instead of category.php Give little reading to template heirarchy on https://developer.wordpress.org/themes/basics/template-hierarchy/ All your custom posts will use taxonomy.php if you have some custom taxonomy defined. For eg: lets suppose there are two taxonomies i.e tax1 & tax2 If you want the same template for ...



Top 50 recent answers are included