• hello, i hope this is simple question for php programers.

    i have wordpress code:

    <?php glmdobcatranpost('21','0','2'); ?>

    and on the place where is 0 (zero) i want to add this

    <?php
    foreach((get_the_category()) as $category) {
        echo $category->term_id . ' ';
    }
    ?>

    thank you coders.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter zedesino

    (@zedesino)

    edit:
    so i’m using plugin category magic. plugin works like that you add three digits (‘x’,’y’,’z’)
    x is first category
    y is second and
    z is number of post i want to show.

    So i have one constant category ‘x’ and 50 different so for each of those 50 categories i have one post that are also in ‘x’ category. And i want when i’m on website.com/category/category-y to be able to read automaticly id of category ‘y’ and to add to plugin query and plugin will show me link to post that is related to category ‘x’ and also to current category ‘y’

    Simply rearrange like this

    <?php
    $categorylist = "";
    foreach((get_the_category()) as $category) {
        $categorylist .= $category->term_id . ' ';
    }
    glmdobcatranpost('21',$categorylist,'2'); ?>

    Thread Starter zedesino

    (@zedesino)

    wow!
    thank you this works great.
    I know was possible but my knowledge of php is bad.

    Interesting, now works perfect, if doesn match two categories i dont get any result. it’s excellent.

    You’re welcome. Your problem description was pretty good. I don’t think I’d do nearly as well asking a technical question in a language other than my native English. I’d probably even mess it up in French. And someone would have to tell me to go look in the manual ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘simple php question’ is closed to new replies.