Tag Info

New answers tagged

0

Create a Page_YourCustomName.php . copy page.php content to your new file. add the following code to first Line : <?php /* Template Name: Your Custom Name */ ?> Once you upload the file to your theme’s folder , go to the Page > Edit screen in your admin dashboard. On the right hand side under attributes you’ll see template. This is where users are ...


0

It should work <?php $my_postid = 1772;//This is page id or post id $content_post = get_post($my_postid); $content = $content_post->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]&gt;', $content); echo $content; ?>


9

singular.php is basically an extra fallback for all post types, regardless if built-in or custom. It comes in straight after single.php and page.php, so you can omit the latter two templates and just have a singular.php template which will be used by all post types in single view. How useful it will be and the necessity of it will, just as with any other ...


5

It's the nature of the WordPress template hierarchy - point being, if you don't have a page.php, it will use singular.php, same if you don't have single.php, it will fallback to a template lower in the hierarchy. Ideal for themes that have the same layout for posts/pages, instead of having duplicate code in each respective template.


-2

It is tricky. I found the answer within a different thread here. WordPress Custom Page Template in a different directory


1

Couple of issues are seen here - You have hooked a function in a template file whereas such code should go in functions.php instead or you can directly put the code of this function in the template. You does not seem to be getting value of $post inside this function. Both the return statements should be removed and just echo $html; should be placed just ...


3

I thought I would provide you with another approach. It is also a bit hackish, but it is general purpose and allows you to simply register the filename and label that you want to use, like so: if ( class_exists( 'WPSE_196995_Page_Templates' ) ) { WPSE_196995_Page_Templates::register_page_template( 'My Page Template', ...


1

Got around with a ugly hack :-/. I will update the answer If I go with jQuery later on. The solution still requires to have template files but code for the template file loads from the index.php I made a new template/ directory and put all page template there. All page templates are blank. We need it only for them to show up on the dropdown. Use ...


0

you can add any custom field with this module https://wordpress.org/plugins/advanced-custom-fields/. And can easily add it to your pages and posts.


0

if You wish to display an image, which is a thumbnail of a post, then use: <?php echo get_the_post_thumbnail( $pageID, 'thumbnail' ); ?> if You wish to display an image from media, then use <?php echo wp_get_attachment_image( $attachmentID, 'thumbnail' ); ?> thumbnail is set for size and is set by default. Size can be changed to ...



Top 50 recent answers are included