Displaying posts on homepage – Template Page

The template tags (like the_content()) aren’t available when using get_posts. In order to make the template tags available, you have to make use of setup_postdata( $post ); Example: <?php $posts = get_posts(‘category_name=category-test’); foreach($posts as $post) { setup_postdata( $post ); the_title(); ?> <p><?php the_content(); ?></p> <?php } ?>

Custom permalink structure for remote content pages

I think your problem has several solutions. If you don’t want to have one entry in WP database for each remote item, a possible solution could be to have a page with property slug and add a rewrite rule to get the ID number: add_action( ‘init’, ‘cyb_property_rewrite_rule’ ); function cyb_property_rewrite_rule() { add_rewrite_rule( ‘^property/([0-9]{1,})/?$’, ‘index.php?pagename=$matches[1]&remote_ID=$matches[2]’, ‘top’ … Read more

Will placing custom templates in sub directory break any native WordPress functionality

Since WP 3.4 page templates can be stored in theme root folder or direct sub-directoryr, that is no problem. But rename page templates, which include moving files to other directories, will unassign that page templates for all pages currently using it. To reassign the page template, simply edit the page, and reselect the desired template. … Read more

Injecting pre-defined text from custom page template to editor

The code below will work, read inline comments. Paste it into your theme functions.php or plugin. The only problem with this is the it will only work when the template is selected and the post is saved/updated and the editor is blank. <?php function wpse_177576_update_editor_content( $post_id ) { if ( wp_is_post_revision( $post_id ) ) return; … Read more

Custom form not showing in correct place on page

When working with shortcode you must return a value rather than output directly. The below amendmetn should fix your positioning issue. For more informaiont, see the Shortcode API Codex, speciffically the Output section. function multipage_form() { global $wpdb; $this_page = $_SERVER[‘REQUEST_URI’]; $page = $_POST[‘page’]; if ( $page == NULL ) { /** * first name … Read more

How can I modify a custom post type and custom page template for a child theme if all content seams to be handled by theme’s ‘native’ plugin?

It seems to me like this is just a regular addition to functions. Since you are asking, I think you may not be getting the result you are looking for. If this was my project, I would create a new plugin, install it into the regular plugin list so that it does not get overwritten … Read more

Pagination for custom loop on custom page template is not displaying anything

Harman, don’t use get_posts() when pagination is required. You may also accomplish this task using WP_Query. Refer to this answer explained beautifully by Chip Bennett at How to fix pagination for custom loops? <?php $user_fav = get_user_favorites($user_id); $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $args = array( ‘posts_per_page’ => … Read more