0

I created custom bootstrap navwalker class for my wordpress theme all things work correctly i has this code below within function start_el(){}

When i put <h2>Hellow World!</h2> within $item_output the dropdwon menu show the Hellow World! four times in four column

But when i want put the the_title() wordpress function within $item_output like this <h2>'.the_title().'</h2> Show me the Hello World! post title above the main menu items, not within the dropdown menu

How i can solve this problem?

if (!empty($item->divideto_4)) {
    $col = 3;
    $divide_to = 12 / $col; //4

    for ($i=0; $i<$divide_to; $i++) {
        $item_output .= '<div class="col-sm-'.$col.'"><h2>Hellow World!</h2></div>';
    }
}
  • 1
    Note the difference between the_* and get_* core functions, is like echo vs return (in most cases). – birgire Jan 4 '16 at 16:19
  • but i have problem the above code only show the latest post means don't show the latest four posts duplicate last post four times – Shwan Namiq Jan 4 '16 at 18:10
  • Can you post more of your code? E.g. the whole start_el() method? – birgire Jan 4 '16 at 18:44
0

Thank you for our reply i solved my problem i used Wordpress loop query for showing last fout posts in four column as below

if (!empty($item->divideto_4)) {
    $col = 3;
    $divide_to = 12 / $col; //4

    $my_query = "showposts = ".$divide_to; 
    $my_query = new WP_Query($my_query);
        while ($my_query->have_posts()) : $my_query->the_post();
        $item_output .= '<div class="col-sm-'.$col.'">';
        $item_output .= get_the_title();
        $item_output .= '</div>';
    endwhile;*/
    $YPE_col_content->YPE_lastposts();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.