Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter speedwheel

    (@speedwheel)

    Thread Starter speedwheel

    (@speedwheel)

    @lucagrandicelli here is the code:

    Class CP_Testimonial {
    	/**
    	 * Initialize all the things
    	 */
    
        public static $post_name = 'testimonial';
        public static $tag_taxonomy = 'testimonial_tag';
    
    	function __construct() {
    		// Actions
            add_action( 'init', array( $this, 'register_cpt' ) );
            add_action( 'after_setup_theme', array( $this, 'register_ct_tags' ), 1 );
    	}
    	/**
    	 * Register the custom post type
    	 */
    	public function register_cpt() {
    		$labels = array(
                'all_items'          => __( 'All Testimonials', 'ediloc' ),
    			'name'               => __( 'Testimonials', 'ediloc' ),
    			'singular_name'      => __( 'Testimonial', 'ediloc' ),
    			'add_new'            => __( 'Add New', 'ediloc' ),
    			'add_new_item'       => __( 'Add New Testimonial', 'ediloc' ),
                'edit_item'          => __( 'Edit Testimonial', 'ediloc' ),
                'update_item'        => __( 'Update Testimonial', 'ediloc' ),
    			'new_item'           => __( 'New Testimonial', 'ediloc' ),
    			'view_item'          => __( 'View Testimonial', 'ediloc' ),
    			'search_items'       => __( 'Search Testimonials', 'ediloc' ),
    			'not_found'          => __( 'No Testimonials found', 'ediloc' ),
    			'not_found_in_trash' => __( 'No Testimonials found in Trash', 'ediloc' ),
    			'parent_item_colon'  => __( 'Parent Testimonial:', 'ediloc' ),
    			'menu_name'          => __( 'Testimonials', 'ediloc' ),
    		);
    		$args = array(
                'labels'              => $labels,
                'description'         => __( 'Testimonials for the website.', 'ediloc' ),
    			'hierarchical'        => false,
    			'supports'            => array( 'title', 'editor', 'thumbnail', 'revisions' ),
    			'public'              => false,
    			'show_ui'             => true,
    			'show_in_rest'        => true,
    			'publicly_queryable'  => false,
    			'exclude_from_search' => true,
                'has_archive'         => false,
                'show_in_menu'        => true,
    		    'show_in_nav_menus'   => true,
    			'query_var'           => true,
                'can_export'          => true,
                'show_in_admin_bar'   => true,
                //'rewrite'             => array( 'slug' => 'testimonial', 'with_front' => false ),
                'menu_position'       => 20,
    			'menu_icon'           => 'dashicons-format-quote',
    			//'template'            => array( array( 'core/quote', array( 'className' => 'is-style-large' ) ) ),
    			//'template_lock'      => 'all',
    		);
    		register_post_type( self::$post_name , $args );
        }
        
        //category type taxonomy tags
        public function register_ct_tags() {
            $labels = array(
                'name' => __( 'Tags', 'ediloc' ),
                'singular_name' => __( 'Tag', 'ediloc' ),
                'search_items' =>  __( 'Search Tag', 'ediloc' ),
                'all_items' => __( 'All Tags', 'ediloc' ),
                'parent_item' => __( 'Parent Tag', 'ediloc' ),
                'parent_item_colon' => __( 'Parent Tag:', 'ediloc' ),
                'edit_item' => __( 'Edit Tag', 'ediloc' ), 
                'update_item' => __( 'Update Tag', 'ediloc' ),
                'add_new_item' => __( 'Add New Tag', 'ediloc' ),
                'new_item_name' => __( 'New Tag Name', 'ediloc' ),
                'menu_name' => __( 'Tags', 'ediloc' ),
            ); 	
    
            register_taxonomy(self::$tag_taxonomy, array(self::$post_name), array(
                'public' => true,   
                'hierarchical' => false,
                'labels' => $labels,
                'show_ui' => true,
                'show_admin_column' => true,
                'show_in_nav_menus' => false,
                'query_var' => true,
                'show_in_rest' => true,
                'rewrite' => array( 'slug' => self::$tag_taxonomy ),
            ));
        }
    
        public static function get_random($limit, $term_ids) {
            $args = array(
                'post_type' => self::$post_name,
                'tax_query' => array( 
                    array( 
                        'taxonomy' => self::$tag_taxonomy,
                        'field' => 'id', 
                        'terms' => $term_ids
                    ) 
                ),
                'orderby'   => 'rand',
                'posts_per_page' => $limit,
             );
            $testimonials = new WP_Query( $args );
            return $testimonials;
        }
    
        public static function get_tags() {
            $tags = [];
            $terms = get_terms( [
                'taxonomy' => self::$tag_taxonomy,
                'hide_empty' => true,
            ]);
            if (!empty($terms)) {
                foreach($terms as $term) {
                    $tags[$term->term_id] = $term->name;
                }
            }
            return $tags;
        }
    }
    new CP_Testimonial();
    • This reply was modified 7 years, 5 months ago by speedwheel.
    • This reply was modified 7 years, 5 months ago by speedwheel.
    • This reply was modified 7 years, 5 months ago by speedwheel.
    Thread Starter speedwheel

    (@speedwheel)

    I think I found the issue, I used WP All Import to import these 28 posts, and in the database they all have the same date (including seconds), so wordpress can’t order them by date using pagination (since they all have the same date). When I order them by title it works fine.

    • This reply was modified 7 years, 5 months ago by speedwheel.
    Thread Starter speedwheel

    (@speedwheel)

    http://www.smarttechno.eu/sample-page/

    It’s still the same, I have new wordpress installation and new plugin installation (latest version).

    Thread Starter speedwheel

    (@speedwheel)

    I put it here for test:

    http://www.smarttechno.eu/?page_id=2

    When I click on any of the 2 images it’s not showing the slider with thumbnails and arrows like it did in the begining.

    Thread Starter speedwheel

    (@speedwheel)

    There are only 2 levels menu, the main menu and the drop down.

    Can you give some hints how to make the ajax call so I can investigate? I’m new in ajax world.

Viewing 6 replies - 1 through 6 (of 6 total)