Support » Plugin: CPT-onomies: Using Custom Post Types as Taxonomies » get_posts – get posts based on the current page

  • Hey,

    First of all: thanks a million for the great plugin. It has proven to be a great support for out new project.

    Now, I am a complete PHP-noob and coding in a theme for the first time. So this might be something really stupid, but I still hope someone can help me. I am working on a videogames website in which we are building a videogame database. Ever game will have a separate archive-page and we want to show an overview of all the articles that have a custom post type Game connected to it. Now I’ve used the code from your website like this:

    <?php $post = get_posts( array(
       'numberposts' => -1, // we want to retrieve all of the posts
       'post_type' => 'post',
       'games' => 'battlefield-4',
       'suppress_filters' => false // this argument is required for CPT-onomies
    ) );
    if( $post ) {
          foreach ( $post as $artikel ) {
             ?><li><a href="<?php echo get_permalink( $artikel->ID ) ?>" title="<?php echo get_the_title( $artikel->ID ); ?>"><?php echo get_the_title( $artikel->ID ); ?></a></li><?php
    } ?>

    This works. But now I want to build it that it automatically replaces Battlefield-4 with the archive page it is on. What do I need to place here to make this happen?

    Any help would be great!



Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘get_posts – get posts based on the current page’ is closed to new replies.