Tag Info

New answers tagged

0

If you have a page, and need to run PHP code that isn't in your standard page template, you can: Use a custom page template Create a template with page-pagename.php Implement and use a shortcode All three are valid and suitable methods for doing this, however, do not: Try to let users place actual PHP code in the post content ( MASSIVE security risk ) ...


3

You can always use the output buffering to store the printing contents in a variable. function return_get_template_part($slug, $name=null) { ob_start(); get_template_part($slug, $name); $content = ob_get_contents(); ob_end_clean(); return $content; } $content = return_get_template_part('content', 'page'); This would be most ...


1

If you want to load a template file, execute the code it contains, and save the results to a variable, you need to use php's output buffering: ob_start(); get_template_part( 'content', 'page' ); $content = ob_get_contents(); ob_end_clean();


0

I found out how to solve this problem, and I hope I can help others in future. My goal was to create an url structure like this: landen/land/rondreizen, with the use of multiple custom post types. 'landen' and 'rondreizen' are both custom post types. The templating structure should wordpress-like, act like this archive/single/archive. After long searching ...


1

I think your problem is how your function is constructed and not your condition as such. You should not be wrapping your function and your action in a condition like this. Page templates are selected really late in the query by the main query, and I probably think that this is way to late for your action to execute. By the time the condition hits true, the ...


0

Please Provide Proper path to enqueue scripts and styles Example- function theme_name_scripts() { wp_enqueue_style( 'style-name', get_stylesheet_uri() ); wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'theme_name_scripts' ); then it will work fine


0

If you're trying to show content beneath admin bar (and I am assuming this is the reason you wanna get rid of admin bar). Have you consider pushing your page down 32px, since body tag has logged-in class that you can use this code to push content down and keep admin bar: body.logged-in: margin-top:32px;


0

Your problem is that you are putting the page result in $page. While the normal commands like the_title() and get_field() will look for the $post variable if you are not setting a seperate ID of which you want the title. I once did this by creating a backup of the $post variable, and then just put each post i wanted to include on the parent page in the ...


0

Add This to your function.php it hide the admin bar from frontEnd add_action('after_setup_theme', 'remove_admin_bar_user'); function remove_admin_bar_user() { if (current_user_can('administrator') || is_admin() ) { show_admin_bar(false); } }


0

Yes, it is possible. I found this example plugin very helpful. Another approach that is come into my head is using WP Filesystem API to create the template file to theme. I am not sure that it is the best approach to take, but I am sure it work!


-1

The problem was only with one set of parent-child. Deleting them and recreating the page solved the issue.


0

Your theme doesn't necessarily include all these template files. It might just use index.php to serve the single page template as well as listings (category, date, author, tag, etc). The articles Theme Development and Template Hierarchy from the codex should get you on the right road with theme development. If you add a single.php file, WP will use that ...


1

You could try the loop_start hook depending on what position you want the image and use the code in your functions file. add_action('loop_start', function() { if(is_page(10)) { echo do_shortcode('[plugin_shortcode 1 .....]'); } else if (is_page(11)) { echo do_shortcode('[plugin_shortcode 2 .....]'); } else if (is_page(15)) { echo ...


0

Might be a problem in your get_header() code? Normally something like a missing curly brace } Try // commenting out the get_header() line and see if that fixes it. Then delve into get_header() (or post the code) and we'll find out whats wrong.


-2

Better thing is that if you have all pages in html format of you current site , following will help you to convert html to wordpress as per your given partition : http://www.wpexplorer.com/create-wordpress-theme-html-1/


0

Did you create a CSS that includes both left and right side bars? /*---------------------------------------------------- 2 sidebars ---------------------------------------------------- */ #sidebar { Float:left; width:20%; display:block; } #sidebar-core { margin-right:20px; } #main { float: left; width: 65%; display: block; } ...


0

Simplest way is to use single_template filter hook (one of the {$type}_template hooks). It is fired by WordPress to filter the template file found for singular post requests. add_filter('single_template', function($template) { $queried = get_queried_object(); if ( $queried->post_type === 'clients_projects' ) { // only for this CPT // file name ...


0

OK. I have found the fix to my problem. Here are the steps: Thanks to Howdy_McGee who found where the problem was (see first answer above) I located the cause of all my pains. Opened the compressed.css file with my cpanel file manager and found the line .column{float:left;margin:0 10px;padding:0;} Then I added the following code ...


0

The widths are the same the problem is that you have this in your compressed.css - Line 55: .column { float: left; margin: 0 10px; padding: 0; } Whenever you float your column left you lose your max-width as it becomes inline. Fix that fix your website. The homepage content, or all the content is in that column class.


0

As Andrew stated, a custom page/template would be the most efficient way to display the calculator. You can leave this as a simple page, displaying just your calculator, or you can add in "the loop" below the calculator to display additional text which would be easily edited in Wordpress.


0

I would use WP_Query with any of the category parameters as its more flexible. You can add it directly to your template or create a template tag which you can then add in any file or custom function. <?php // The Query $the_query = new WP_Query( 'cat=4' ); // The Loop if ( $the_query->have_posts() ) { echo '<ul>'; while ( ...



Top 50 recent answers are included