• Resolved panicfomo

    (@panicfomo)


    Hello,

    Thanks for a great plugin!

    I’m trying to come up with PHP code that will basically do this:
    If this wiki page is of that wiki category, output a shortcode

    I’m sure this is easy to write but I’m not much of a coder so looking at the source code didn’t give me any clues. Please help!

    Many thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author dmccan

    (@dmccan)

    Hi @panicfomo – I hope all is well with you.

    Where are you thinking to put this code? In your child theme? If so, what theme are you using? What shortcode are you wanting to output? Where do you want the shortcode’s output to go?

    Thanks,

    David

    Thread Starter panicfomo

    (@panicfomo)

    This code will be executed by XYZ PHP Code plugin. (it allows to run PHP code in random places by wrapping it in shortcodes)

    This code should be executed in the context of a wiki page. The PHP shortcode will be inserted in a content template in Impreza theme. https://themeforest.net/item/impreza-retina-responsive-wordpress-theme/6434280

    A shortcode would display a page block (some HTML output) in the theme.

    Basically, I need to know how to check if that wiki page belongs to a certain wiki category.

    if ( wiki_category == 'X' ) echo 'Y';

    I can take it from there.

    Plugin Author dmccan

    (@dmccan)

    You can try this:

    // this should be placed within the loop of the template outputting the wiki page
    $myterms = get_the_terms( get_the_ID() , 'wiki_cats' );
    if ( $myterms != null ){
    	foreach( $myterms as $term ) {
    		//substitute your category for quick-snacks
     		if ($term->slug=="quick-snacks") {
    			print "found match"."<br/>";
    		}
    		//you can remove the next line. it is here to help you see what is being returned
    		print $term->slug."<br/>" ;
    		//you should probably keep this
    		unset($term);
    	}
    }
    ?>

    I hope this helps.

    Thread Starter panicfomo

    (@panicfomo)

    That’s what I was looking for. Thank you so much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Query the category of a wiki page’ is closed to new replies.