• Hi,

    Can someone help me on how to create Shortcode, or how to add my custom post type to a certain page via shortcode?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter KDSinc

    (@welvincudas)

    I have my custom post type named “projects” how could i query those custom post (projects)? Also, displays title, excerpt post and featured image.

    im newbie. sorry. i really appreciate helps.

    thanks

    Create another file in your template folder (line custom-page.php)
    add this at the top of the page

    <?php
    Template Name: my custom page
    ?>

    Copy entire page.php inside, and find the loop (if(have_post)…..)
    and change it to

    global $paged;
    $wp_query = new WP_Query;
    query_posts("posts_per_page=4&post_type=projects&paged=$paged");
    	while (have_posts()) : the_post();

    and also delete endif(); if you have it after endwhile();
    Than create another page in wp-admin, and on the right hand side, choose ‘my custom page’ template.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post Type, Page to Homepage or Shortcode’ is closed to new replies.