Custom query problem
-
Hello, I want to make a post listing on my theme using the plugin. Basically what we want to do has been shared in the last 24 hours
and listing the posts with the most views. I was able to list on Elementor by following the instructions in this article.But I couldn’t do the same things on my own theme. I tried to do it by following the steps in this link but I don’t know what to put where so i haven’t succeed.
The theme adds its own features and instead of using the Elementor Query tab, it has added its own “Post Source” field, and from here only i can list queries the inside of the theme.
. The queries are added to the theme file as follows.
loop-options.php
'sort_by' => [ 'label' => esc_html__('Sort By', 'bunyad-admin'), 'type' => 'select', 'options' => [ '' => esc_html__('Published Date', 'bunyad-admin'), 'modified' => esc_html__('Modified Date', 'bunyad-admin'), 'random' => esc_html__('Random', 'bunyad-admin'), 'comments' => esc_html__('Comments Count', 'bunyad-admin'), 'alphabetical' => esc_html__('Alphabetical', 'bunyad-admin'), 'rating' => esc_html__('Rating', 'bunyad-admin'), ] + ( // Not using global setting for now. class_exists('\Jetpack') && \Jetpack::is_module_active('stats') ? ['jetpack_views' => esc_html__('JetPack Plugin Views Count', 'bunyad-admin')] : [] ), 'condition' => ['query_type' => 'custom'], ], 'sort_days' => [ 'label' => esc_html__('Sort Days', 'bunyad-admin'), 'description' => esc_html__('Number of days to use for the views sort. Max limit is 90 days for Jetpack.', 'bunyad-admin'), 'type' => 'number', 'default' => 30, 'condition' => [ 'sortby' => 'jetpack_views', 'query_type' => 'custom' ] ],
query.php
/** * Sortng criteria */ switch ($sort_by) { case 'modified': $query_args['orderby'] = 'modified'; break; case 'random': $query_args['orderby'] = 'rand'; break; case 'comments': $query_args['orderby'] = 'comment_count'; break; case 'alphabetical': $query_args['orderby'] = 'title'; break; case 'rating': $query_args = array_replace( $query_args, [ 'meta_key' => '_bunyad_review_overall', 'orderby' => 'meta_value_num' ] ); break; }
How can I add WPP plugin queries here and make it list.
- The topic ‘Custom query problem’ is closed to new replies.