New answers tagged

-1

Shortcodes are intended to return values, or echo them. You can use the include to the file you have, but unless you serve the intended $atts to the function there you won't see anything. Basically no one can help you unless we see the rest of your code. My best guess is that you need to declare the variable globally from the attributes in the shortcode and ...


1

You are probably confused by the output of array_values() which will always get you only array values without keys while $atts variable is actually an associative array. To extract your attribute use $arr = $atts['tablepageid']; Cheers


0

You need to use get_template_directory(), this function will return local server path of you template and then you can use that path to access required file. So in your case it would be something like below: include get_template_directory() . "/Sorting.php"; PS: Mind the spelling of your file.


1

Duplicate the post.php in your theme folder. Rename that file as any_name.php Enter the following code at the top of that file. < ?php /* Template Name: Any Name */ ?> Add your php codes to that file. Go to admin panel -- > Create a new page -- > Select your template and publish the page


2

There are two typical approaches, depending on what you need and consider a page. First is a whole page page, HTML markup and everything. In this case the proper way is usually to create a template in your theme (or child theme), following template hierarchy and modify it. Another approach would be to use hooks to insert your changes, which is more typical ...


0

Must be something with your setup. Following works for me (inside child theme - should work for any theme though): single.php: global $post; $bla = $post->post_title; error_log('post title is: ' . $bla); include('included.php'); included.php: error_log('i am included file: ' . $bla); Output in debug.log: post title is: Hello test i am included ...


-1

Thanks! Found the problem: I activated comments in settings, but there´s a checkbox for each post in the post edit screen. Without that activated, it won´t even throw an error.


1

Just as @Jevuska mentioned, you can use the $post_id as an argument here, in fact, you can also use a ton of optional $args as well <?php comment_form( $args, $post_id ); ?> You can find the information in the Codex here: https://codex.wordpress.org/Function_Reference/comment_form



Top 50 recent answers are included