Tagged: wordpress Toggle Comment Threads | Keyboard Shortcuts

  • Christofian 11:26 pm on January 27, 2012 Permalink
    Tags: , wordpress   

    Use The WordPress Excerpt For The Meta Description 

    add this code in your header:

    <?php if ( is_singular() && $post->post_excerpt != '' ) {
    	$metadesc = get_the_excerpt();
    	echo '<meta name="description" content="' . $metadesc . '" />';
    }?>
    Advertisements
     
  • Christofian 11:24 pm on January 27, 2012 Permalink
    Tags: wordpress   

    http://dimox.net/wordpress-breadcrumbs-without-a-plugin/

     
  • Christofian 12:54 am on December 31, 2011 Permalink
    Tags: wordpress   

    Get Post Count Of WP_Query 

    $the_query_new = new WP_Query(array('post_type' => 'grade', 'assignment' => $theassignmentID));
    $points3 = $the_query_new->found_posts;
    

    create a new wp_query, then do

    $wp_query_variable->found_posts

    That will give you the number of posts that the wp_query finds.

     
  • Christofian 5:24 pm on December 27, 2011 Permalink
    Tags: wordpress   

    WordPress Loop Within A Loop 

    This was really complicated until I read http://codex.wordpress.org/The_Loop#Multiple_Loops_Example_2. What I was doing wrong was I forgot to do this:

    Note: In PHP 5, objects are referenced with the “= clone” operator instead of “=” like in PHP 4. To make Example 2 work in PHP 5 you need to use the following code: –http://codex.wordpress.org/The_Loop#Multiple_Loops_Example_2

    here’s the code:

    $the_query_new = new WP_Query( $args );
    
    // The Loop
    while ( $the_query_new->have_posts() ) : $the_query_new->the_post();
    $temp_query = clone $the_query_new;  // store it
    //loop blah blah
    
    //A Loop Within A Loop
    
    $the_query_new = new WP_Query($args);
    
    while ($the_query_new->have_posts()) : $the_query_new->the_post();
    // -- your new loop -- //
    echo "hi ";
    endwhile;
    //if (isset($the_query_new)) $the_query_new = $temp_query;} // restore loop
    $the_query_new = clone $temp_query; //restore loop
    
    endwhile;
    
    // Reset Post Data
    wp_reset_postdata();
    
     
    • Christofian 5:28 pm on December 27, 2011 Permalink

      if you have any questions, post them in the comments 🙂

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel