• Resolved widowmain1

    (@widowmain1)


    i got it set to post a custom post type but it also posts the default, how can i stop if from posting default? thank you.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Nicola Mustone

    (@nicolamustone)

    Automattic Happiness Engineer

    Hello,
    Do you mean how to stop posting the regular WordPress posts?

    You can use this code in functions.php:

    add_filter( 'wp_discord_post_is_new_post', 'wp_discord_post_block_regular_posts' );
    function wp_discord_post_block_regular_posts( $new_post ) {
        global $post;
    
        if ( $post->post_type === 'post' ) {
            return false;
        }
    
        return $new_post;
    }
    Thread Starter widowmain1

    (@widowmain1)

    this is very strange… it was working at first but now it wont post anything to my discord at all and ive changed nothing.

    my custom post type is question, could you write me the code and i will literally copy and paste it to my child functions.php? i must be doing something wrong somehow.

    im sorry to ask this.

    Plugin Author Nicola Mustone

    (@nicolamustone)

    Automattic Happiness Engineer

    You want to post the question or not? Not sure to understand what you want to post and what you want to exclude.

    Thread Starter widowmain1

    (@widowmain1)

    I only want to include the post type question

    Plugin Author Nicola Mustone

    (@nicolamustone)

    Automattic Happiness Engineer

    Try with this

    add_filter( 'wp_discord_post_is_new_post', 'wp_discord_post_block_regular_posts' );
    function wp_discord_post_block_regular_posts( $new_post ) {
        global $post;
    
        if ( $post->post_type !== 'question' ) {
            return false;
        }
    
        return $new_post;
    }
    Thread Starter widowmain1

    (@widowmain1)

    Can’t get it to work anymore… seems it isn’t working with my custom post type because I’m doing everything correctly.

    when I don’t use custom post type it works fine. @nicolamustone

    I’m using the Discy theme, top-ranked and best selling theme on Envato btw so it would be a good idea to get it working with Discy.

    Also asked if they use a custom post plugin and they do not.

    • This reply was modified 7 years, 10 months ago by widowmain1.
    • This reply was modified 7 years, 10 months ago by widowmain1.
    • This reply was modified 7 years, 10 months ago by widowmain1.
    • This reply was modified 7 years, 10 months ago by widowmain1.
    Thread Starter widowmain1

    (@widowmain1)

    doesn’t work at all now actually… I feel like it did something to my WordPress.

    decided to delete my bot and everything and try to start fresh tomorrow, hopefully, I can at least get it working again.

    • This reply was modified 7 years, 10 months ago by widowmain1.
    Plugin Author Nicola Mustone

    (@nicolamustone)

    Automattic Happiness Engineer

    If it still does not work can you send me a copy of the theme to nicola [at] mustone [dot] blog?

    We will keep the conversation here though, so others can read if needed.

    Thanks!

    Thread Starter widowmain1

    (@widowmain1)

    Hi, even after you edited my functions.php file for me it still doesn’t work correctly.

    When a user asks a question from the front end of my website it doesn’t send the notification to my discord channel but when I ask a question from the dashboard end of my site it sends the notification correctly.

    Note that with the default settings it does work properly but sends all notifications, I need the custom filter you added for me to work properly, unfortunately. @nicolamustone

    Hi @nicolamustone,

    I have the same problem, looks like $post and $new_post are wiggy.

    Here is my small test:

    add_filter( 'wp_discord_post_is_new_post', 'wp_discord_post_block_regular_posts' );
    function wp_discord_post_block_regular_posts( $new_post ) {
      global $post;
        if ( wp_discord_post_is_logging_enabled() ) {
          error_log( sprintf( 'myOwnFilter: post_type: %s', $post->post_type ) );
          error_log( sprintf( '-- post: %s', json_encode( $post )));
          error_log( sprintf( '-- new_post: %s', json_encode( $new_post )));
        }
      return $new_post;
    }

    Log:

    Array\n(\n    [id] =] 1174\n    [status] =] publish\n    [date] =] 2018-10-20 23\n    [current_time] =] 2018-10-20 23\n)\n
    WP Discord Post - Post 1174 maybe is new. _wp_discord_post_published = 
    myOwnFilter: post_type: 
    -- post: null
    -- new_post: true

    I’m using WordPress 4.9.8 with PHP 7.2, Wellington Theme and plugin-version 2.1.0

    • This reply was modified 7 years, 7 months ago by jensherrmann.
Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘How can i exclude a post type?’ is closed to new replies.