• Resolved dtszero

    (@dtszero)


    Hi!

    I want to show my custom post types in the default homepage of amp, I already added the support on Settings->General->AMP Support->Custom Post Types.

    But in the,
    Design->Homepage->Loop Display Controls->Post Type in Loop,
    I can only select one.

    Someway to choose multiple Post Type?

    Regards,

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @dtszero,

    Do you want to show the loop for multiple Custom Post Types?

    Thread Starter dtszero

    (@dtszero)

    Hi @marqas,

    Yes I have 4 custom post types and I want to show all of this with the WordPress default ‘post’ on my homepage.

    In my normal theme I use this code to show up all

    // Show on home
    function print_ani_man_posts($query) {
      if( !is_admin() && $query->is_main_query() && is_home() ) {
        $query->set('post_type', array('post', 'anime', 'manga', 'pelicula', 'ova'));
      }
    }
    add_action('pre_get_posts', 'print_ani_man_posts');
    # Show on home
    

    But isn’t working with AMP.

    Thread Starter dtszero

    (@dtszero)

    I found an article on your blog, https://ampforwp.com/tutorials/article/modify-homepage-posts-loop-amp-version-right-way/

    I leave a part of the your code:

    <?php
    /*
    Plugin Name: AMP Home Page Modify
    Version: 0.0.1
    Author: Mohammed Khaled
    Author URI: https://ampforwp.com/
    Donate link: https://www.paypal.me/Kaludi/5
    License: GPL2
    */
    // Exit if accessed directly.
    if ( ! defined( 'ABSPATH' ) ) exit;
    
    //Use Case 2: Show posts from different Post types
    function ampforwp_return_loop_args(){
        // learn more to Modify args @ https://developer.www.ads-software.com/reference/classes/wp_query/
        //remove code between these comments and replace with your code here
      $q = array(
                'post_type'           => array( 'post', 'custom_1', 'custom_2' ),
                'orderby'             => 'date',
                'ignore_sticky_posts' => 1,
                );
        return $q;
    }
    function ampforwp_custom_home_output(){
      add_filter('ampforwp_query_args', 'ampforwp_return_loop_args');
    }
    add_action('amp_init','ampforwp_custom_home_output');
    

    Thanks! I solve this,

    Regards,

    • This reply was modified 6 years, 1 month ago by dtszero. Reason: ; fix
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show multiple Post Types in homepage’ is closed to new replies.