• I have a shortcode I use to get the form at the bottom of the attached page a contact form 7. But I also send this in an RSS e-mail, which sends out the [shortcode], so I am trying to clean it up.

    I have excluded this category in the PHP code, but am wondering if I can add another line calling for a specific shortcode for this category.

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Corey Salzano

    (@salzano)

    I think the answer is yes, but I’m not sure what you mean by “calling for a specific shortcode for this category.”

    I think you’re asking how you prevent the shortcode you’re adding to posts with my plugin to be removed from RSS feeds.

    I’m not aware of a way to check if the content is being prepared for an RSS feed inside a filter on the_content, which is how this plugin works. I would probably write a separate small plugin that uses the_content_feed to remove the shortcode that you are using this plugin to add.

    https://developer.www.ads-software.com/reference/hooks/the_content_feed/

    Thread Starter paulmil11

    (@paulmil11)

    The RSS feed isnt a big deal. I am basically just trying to create a “bottom of a single category post” solution and I will be set.

    Plugin Author Corey Salzano

    (@salzano)

    Add a !has_category('portfolio') clause to the condition in the plugin. Instructions in this post https://coreysalzano.com/wordpress/bottom-of-every-post/

    Thread Starter paulmil11

    (@paulmil11)

    I already have a main function, so I would need to do a !has_category and then call a different file or specific shortcode. can i do that in php?

    Plugin Author Corey Salzano

    (@salzano)

    Thread Starter paulmil11

    (@paulmil11)

    I perhaps got a bit too complicated but this seemed to break the plugin instead of work:

    if( !is_page( ) && has_category(‘BoundlessReads’) do_shortcode(‘[contact-form-7 id=”997″ title=”BoundlessReads Signup”]’);
    if( !is_page( ) && !has_category(‘thoughts’) && !has_category(‘BoundlessReads’) && file_exists( $fileName )){

    the 2nd line was working before i added the first

    Plugin Author Corey Salzano

    (@salzano)

    I think you’ve just got a syntax error because of a missing parenthesis. You could enable debugging and use /wp-content/debug.log to confirm errors like this.

    if( !is_page( ) && has_category('BoundlessReads') ) { do_shortcode('[contact-form-7 id="997" title="BoundlessReads Signup"]'); }

    Thread Starter paulmil11

    (@paulmil11)

    what line would you put that in – before or after the main one on line 27?

    Plugin Author Corey Salzano

    (@salzano)

    I simply rewrote your first condition. The way you’ve put one if condition before the one that’s already in the plugin means that they’ll both run in order they appear in the file. So, your code with my correction reads, “if this is a page with category BoundlessReads, do the BoundlessReads Signup form shortcode.” Then, after that, the next if will run. It says, “if this is not a page and does not have category thoughts and does not have category BoundlessReads and the text file that comes with the plugin exists.” Your clipping doesn’t include anymore code, but the code that comes after that includes the text file.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Exclude one category and then add shortcode to that category?’ is closed to new replies.