Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author metaphorcreations

    (@metaphorcreations)

    There is not a parameter for categories yet, but I will add that into the next update. If you are familiar with using WordPress filters, you can add/modify the post query any way that you’d like using:

    function custom_post_block_query_args( $args ) {
    	$args['category_name'] = 'my-category';
    	return $args
    }
    add_filter( 'mtphr_post_block_query_args', 'custom_post_block_query_args' );
    Thread Starter msbodetti

    (@msbodetti)

    Thanks for the reply!

    Will this update all the post blocks?

    Plugin Author metaphorcreations

    (@metaphorcreations)

    Yes, but you could figure out an if/then statement based on the other $args being passed through to limit the additional argument to only certain post blocks. I don’t have time to go more in depth on that right now, but if you need more help let me know.

    Thread Starter msbodetti

    (@msbodetti)

    It’s not working, I don’t know if it needs a specific or other $tag.
    Please assist. Or if you have any updates on your plugin, let me know. Thanks 🙂

    <?php
    /*
    Plugin Name:
    Plugin URI:
    Description:
    Author:
    Author URI:
    Version: 1.0
    */
    
    function custom_post_block_query_args($args){
    	$args['category_name'] = 'News';
    	return $args;
    }
    
    add_filter('mtphr_post_block_query_args', 'custom_post_block_query_args');
    ?>
    Plugin Author metaphorcreations

    (@metaphorcreations)

    Try using:

    $args['category_name'] = 'news';

    otherwise try a different category query method, like:

    $args['cat'] = '22';

    Where “22” is the category ID of the category you are trying to filter.

    Thread Starter msbodetti

    (@msbodetti)

    Still not working..

    Have you tried this already?

    Thread Starter msbodetti

    (@msbodetti)

    I just added it to your plugin general.php file and it works:

    Line 193 Function:

    function mtphr_post_block( $atts, $content = null ) {
    	extract( shortcode_atts( array(
    		'id' => '',
    		'class' => '',
    		'type' => 'post',
    		'orderby' => 'date',
    		'order' => 'DESC',
    		'offset' => '0',
    		'trim' => 120,
    		'category_name' => 'news'
    	), $atts ) );

    Would like it to work as a parameter though..

    Plugin Author metaphorcreations

    (@metaphorcreations)

    I just tested my first example and it was working fine. I was missing a “;” after “return $args”, which may have caused an issue. It should be:

    function custom_post_block_query_args( $args ) {
    	$args['category_name'] = 'news';
    	return $args;
    }
    add_filter( 'mtphr_post_block_query_args', 'custom_post_block_query_args' );

    But, I will be adding this argument in the next update in the next few weeks.

    Thread Starter msbodetti

    (@msbodetti)

    I did add the semi-colon after the return, it still wasn’t working. Look above.

    Unless you weren’t using it in your Zen Theme, and it worked.

    Thread Starter msbodetti

    (@msbodetti)

    Well it worked for me by editing your general.php file. Looking forward to getting your update for the plugin!

    Plugin Author metaphorcreations

    (@metaphorcreations)

    Ok. Well, I’ll try to get that update out soon.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Post block for specific category’ is closed to new replies.