Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Where do I add code?

Discussion in 'Misc WordPress Requests' started by leunam12, Dec 15, 2017.

  1. leunam12


    Where do I add code?, by leunam12

    Hi, I am new to the forums and new to WordPress, after googling for many days I and not being able to find a satisfactory answer I ahve decided to post here. Basically my question is where do I put code in wordpress? I have been searching for answers to many questions I have and many times the answer that I find is: “use this code” and the code, but I have never seen an explanation of where to put that code and how. I have read and watched tutorials about wordpress but they don’t deal with this issue.

    Example: I have been looking for a way to display all the subcategories of a certain category on a page. I found this answer: use this code…`$args = array(‘child_of’ => 17);
    $categories = get_categories( $args );
    foreach($categories as $category) {
    echo ‘<p>Category: <a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in %s” ), $category->name ) . ‘” ‘ . ‘>’ . $category->name.'</a> </p> ‘;
    echo ‘<p> Description:’. $category->description . ‘</p>’;
    echo ‘<p> Post Count: ‘. $category->count . ‘</p>’;

    Great!! But where do I place that code? I put it on the page and it didn’t work. I created a custom page template and put it there and it didn’t work; I added php tags at the beginning and the end and it didn’t work. Pretty frustrating. I know, I know, i am a newbie and I have to be patient but I need help.


    Where do I add code?

Share This Page

Monarch Social Sharing Plugin