• Resolved Darkmaso

    (@darkmaso)


    I would like to filter the posts by category, showing only those belonging to both catogories.

    For example, if I write: category = "1,2"

    I see posts of categories 1 or 2. (boolean OR)

    Instead, is it possible to see only posts that are part of category 1 and 2? (boolean AND)

    Thank you.

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

Viewing 15 replies - 1 through 15 (of 24 total)
  • Plugin Author pluginandplay

    (@pluginandplay)

    Hello,

    When you add the category parameter in the shortcode and pass the multiple category ids, then it will show the posts of respective categories.

    For eg : if you are using category="1" then plugin will show posts added in category id=1 and if you use category="1,2,3" then plugin will show all posts for category ids = 1,2,3

    Thread Starter Darkmaso

    (@darkmaso)

    Hello, thanks for the reply.

    With category = "1,2,3" I can filter all the posts that are part of the category 1 or 2 or 3.

    I wanted to ask if it was possible to filter only the posts that satisfy the condition of being part of the categories 1 and 2 and 3.

    For example.
    Post A = category 1,2
    Post B = category 1.3
    Post C = category 1,2,3

    With category = "1,2,3" I see all three posts.

    How can I filter only posts that are part of category 1 & 2 at the same time?
    I would like the result to show only Post A and Post C

    Is it possible?

    Plugin Author pluginandplay

    (@pluginandplay)

    Hello,

    Sorry its not possible or i need to check in deep ??

    Plugin Author pluginandplay

    (@pluginandplay)

    Hello @darkmaso

    Ok i have one solution where you can achieve this. I have made a small change in grid shortcode file the :
    blog-designer-pack –> includes –> Shortcodes –> bdp-post.php
    Open this file and go to line #90 where i have added a operator=> 'AND'

    Here is old code:

    if($cat != "") {		
    	$args['tax_query'] = array(
    		array( 
    			'taxonomy' 			=> BDP_CAT,
    			'field' 			=> 'term_id',
    			'terms' 			=> $cat,									
    			));
    	}

    Here is updated code:

    if($cat != "") {		
    		$args['tax_query'] = array(
    			array( 
    				'taxonomy' 			=> BDP_CAT,
    				'field' 			=> 'term_id',
    				'terms' 			=> $cat,
    				'operator'			=> 'AND',									
    		));
    	}
    Plugin Author pluginandplay

    (@pluginandplay)

    Hello @darkmaso

    Ok i have one solution where you can achieve this. I have made a small change in grid shortcode file the :
    blog-designer-pack –> includes –> Shortcodes –> bdp-post.php
    Open this file and go to line #90 where i have added a operator=> 'AND'

    Here is old code:

    if($cat != "") {		
    	$args['tax_query'] = array(
    		array( 
    			'taxonomy' 			=> BDP_CAT,
    			'field' 			=> 'term_id',
    			'terms' 			=> $cat,									
    			));
    	}

    Here is updated code:

    if($cat != "") {		
    		$args['tax_query'] = array(
    			array( 
    				'taxonomy' 			=> BDP_CAT,
    				'field' 			=> 'term_id',
    				'terms' 			=> $cat,
    				'operator'			=> 'AND',									
    		));
    	}
    Thread Starter Darkmaso

    (@darkmaso)

    Hi, I saw your second answer on the email. Here it does not appear.

    I can not find the “bdp-post.php” file in the “blog-designer-pack” folder. In fact, inside the plugin folder I do not have “blog-designer-pack”. Maybe because I installed the plugin directly from wordpress?

    But I understood the change you made, I think it could be something that you can add to the plugin. I find it very useful to filter categories using logical operators to show specific posts on different pages.

    Plugin Author pluginandplay

    (@pluginandplay)

    Hello @darkmaso

    Can you please share the plugin that you are using with a screenshot (under plugin section)?

    Thread Starter Darkmaso

    (@darkmaso)

    Plugin Author pluginandplay

    (@pluginandplay)

    Hello,

    Here you can find our plugin: https://screenshots.firefox.com/JO0KbdzX7D7UMG13/photos.google.com

    I have found that you are using lots of plugins BUT your FTP showing few plugins. Are you accessing right FTP?

    Plugin Author pluginandplay

    (@pluginandplay)

    Hello @darkmaso

    Any update?

    Thread Starter Darkmaso

    (@darkmaso)

    Hi, I was working on it … I modified the .php file you indicated to me.
    Now I do not know what the correct shorcode is for testing it.

    I tried, without success …
    category = "1,2"
    category = "1&2"
    category = "1,&,2"
    category = "1"&"2"

    Thread Starter Darkmaso

    (@darkmaso)

    Hi, can you help me with the right syntax?

    Plugin Author pluginandplay

    (@pluginandplay)

    Hi @darkmaso,

    Sorry for the delay.

    There will be no change in the shortcode and parameter.

    You have to pass categories like this comma separated
    category="1,2"

    So only those post will come which has category assigned 1 and 2.

    Kind Regards,

    Thread Starter Darkmaso

    (@darkmaso)

    Hello, thanks for the reply. Now I understand, I had made a mistake.

    I modified the file you indicated correctly, but then on wordpress I used bdp_post_carousel instead of bdp_post.

    With bdp_post it works, but I wanted to use it with the carousel, I tried to copy the same code in the .php of the carousel, in line 108 but in this way the plugin got an error.

    Plugin Author pluginandplay

    (@pluginandplay)

    Hello,

    If you open this file : bdp-recent-post-carousel.php then go to line no : 101 and check the code with if($cat != "") {

    Now under this if condition add one more line after 'terms' => $cat ie 'operator' => 'AND'

    So complete code will be:

    'taxonomy' 			=> BDP_CAT,
    'field' 			=> 'term_id',
    'terms' 			=> $cat,
    'operator'			=> 'AND',
Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘Filter multiple categories’ is closed to new replies.