Tag Info

Hot answers tagged

2

Global $post var is set by WP::register_globals() method. It is called by WP::main() method, on its turn called by wp() function that is called when wp-blog-header.php is loaded. If you look at the graph @Rarst built, on the left, you can see where wp() function is called. In terms of hooks, global post variable is set just before "wp" hook runs, so that ...


1

This can be achieved many ways. But, the below method is most prominent to me. add_filter('the_title', 'wpse165333_the_title', 10, 2); function wpse165333_the_title($title, $post_ID) { if( 'nav_menu_item' == get_post_type($post_ID) ) { if( 'taxonomy' == get_post_meta($post_ID, '_menu_item_type', true) && 'category' == ...


1

Try this query, remembering to change out your_posts_table with the proper name in your database. Using CONCAT, you can add any number of strings, just pass post_name to add your changes before/after. update your_posts_table set post_name = CONCAT('pre-', post_name) More info on MySQL CONCAT Note: Use a WHERE clause if you only want to update specific ...


1

Yep, it's not very common, but perfectly viable and nifty technique. After the posts are retrieved in WP_Query they are passed through the_posts filter like this (where $this is WP_Query instance): $this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) ); You just loop through array and assign the extra data you need ...


1

Try just using the traditional $i iterator (untested) but I can't see why this wouldn't work.. <?php $i = 0; while ( have_posts() ) : the_post(); $i++; if ( $i == 1 ): ?> <!-- First Post --> <div id="post"> <a class="post_image" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> ...


1

Found the solution: $content = apply_filters('the_content', $post->post_content);


1

Both answers so far are correct but a more thorough answer seems warranted. If you use this: $content = wpautop( $post->post_content ); you're applying the one function that adds paragraph tags to post content. wpautop() is one of many functions (including plugin functions at times) that hooks onto the_content, so if you do this: $content = ...


1

WordPress uses the attachment filename to create the attachment post slug. If your file was named something else, there would not be any conflicts. If you have your post permalinks set to /%postname%/ , and you upload an image FIRST, and then create a post SECOND, then WordPress has to make a choice between the two when someone tries to access the ...



Only top voted, non community-wiki answers of a minimum length are eligible