Is there a way to sort posts by ‘random order’ with this plugin? I am trying to randomize ‘current query’ posts and this cannot be done on Elementor it seems. If there is a way this plugin could do it, would be much appreciated.
Kind regards
]]>I’ve seen it as an option on a few plugins, but I’m not sure how easy it would be to add?
]]> function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() && is_shop() ) {
$hideProducts = array();
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'product',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'sell_product_online',
'value' => '1',
'compare' => '=',
),
),
));
foreach ($posts as $another) {
array_push($hideProducts, $another->ID);
}
$q->set( 'post__not_in', $hideProducts );
}
remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
}
Any help appreciated.
]]>We checked different approaches and came up with this Query and Shortcode:
Define what can overwrite the shortcode.
// Query
function companyname_add_query_vars( $vars ) {
array_push($vars, "id", "partner", "owner", "redirect");
return $vars;
}
add_filter( 'query_vars', 'companyname_add_query_vars' );
Define what will be passed from shortcode to form
// Shortcodes
function companyname_zoho_form_shortcode($atts)
{
// normalize attribute keys, lowercase
$atts = array_change_key_case((array)$atts, CASE_LOWER);
// override default attributes with user attributes
$companyname_atts = shortcode_atts([
'url' => '',
'source' => 'Websites',
'class' => 'zohoform',
'id' => get_query_var('id', 'zohoform'),
'redirect' => get_query_var('redirect', ''),
'owner' => get_query_var('owner', 'Abstract of Default Username'),
'partner' => get_query_var('partner', 'Default Referal Partner'),
], $atts, 'companynamezohoform');
// start output
$url = esc_html__($companyname_atts['url'], 'companyname').'?partner='.esc_html__(urlencode($companyname_atts['partner']), 'companyname').'&owner='.esc_html__($companyname_atts['owner'], 'companyname').'&redirect='.esc_html__($companyname_atts['redirect'], 'companyname');
$o = '<iframe id="'.esc_html__($companyname_atts['id'], 'companyname').'" class="zohoform" style="width:100%;border:none;overflow:hidden;" src="'.esc_url($url).'" scrolling="no" frameborder="0">';
// enclosing tags
if (!is_null($content)) {
// secure output by executing the_content filter hook on $content
$o .= apply_filters('the_content', $content);
// run shortcode parser recursively
$o .= do_shortcode($content);
}
// end box
$o .= '</iframe>';
// return output
return $o;
}
function companyname_shortcodes_init() {
add_shortcode('companynamezohoform', 'companyname_zoho_form_shortcode');
}
add_action('init', 'companyname_shortcodes_init');
And use this in raw HTML or Editor
[companynamezohoform id="CSS added to form" partner="Referal Partner XYZ" owner="Abstract of Username" redirect="URL" url="https://forms.zohopublic.com/companyname/form/ZohoCRMB2BPartnerAnmeldung/formperma/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]
]]>We currently Selected the “POST” Query Option in the Post type.
But when we get to the actual site. There are some published articles as “PAGE” showing up.
We temporarily but the PAGE IDs in the exclude section.. But we want to make sure that we aren’t adding PAGE ID everytime we publish new PAGE.
Is there any way we could make the plugin show up only the articles that are published as “POST” not “page”
Here is the screenshot of the settings: https://take.ms/bHdDx
]]>I know it must be something simple, but I just can’t figure it out!
Thanks in advance.
https://www.ads-software.com/plugins/live-composer-page-builder/
]]>Ex.: I want to get video posts from Car category.
]]><?php
query_posts( array ( 'post_type' ='product', 'product_cat' = 'newly-released', 'post_per_page' = 4 ) );
while (have_posts()) : the_post();
<h2><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h2>
<a href="<?php the_permalink() ?>"><?php echo get_the_post_thumbnail(); ?></a><?php the_excerpt(); ?>
<hr/>
endwhile;
wp_reset_query();
?>
]]> `<?php
function post_in_language()
{
if (isset($_GET[‘lan’]))
{
if($_GET[‘lan’] == ‘en’)
{
$post_in_english = 7;
}else{
$post_in_english = 6;
}
}
else{
$post_in_english = 6;
}
}
?>
<?php post_in_language(); ?>`
What I’m trying to do is to change the ID of a category so one category is in english the other in albanian. the post query:
`<?php
$catquery = new WP_Query( ‘cat$post_in_english&posts_per_page=3’ );
while($catquery->have_posts()) : $catquery->the_post();
?>`
as you can see I’m tying to change the ID with an variable but it does not work.
The site is no temple I working on in from scratch.
there are no error showing with this variable assignet to the category (cat…).
also tryed:
<?php
$catquery = new WP_Query( ‘cat=<?php $post_in_english; ?>&posts_per_page=3’ );
while($catquery->have_posts()) : $catquery->the_post();
?>