Static posts page with home.php
get_queried_object() stores the original object that was found as a match for the permalink. It’s the WP_Post object of your News Page $news_page = get_queried_object(); echo $news_page->post_title;
get_queried_object() stores the original object that was found as a match for the permalink. It’s the WP_Post object of your News Page $news_page = get_queried_object(); echo $news_page->post_title;
You could hook into template_redirect and execute a helper function: add_action( ‘template_redirect’, ‘wpse_75558_count’ ); function wpse_75558_count() { if ( is_singular() ) setPostViews( get_the_ID() ); } To display the post views, you have to use a later hook. I would recommend the_content: add_filter( ‘the_content’, ‘wpse_75558_show_count’ ); function wpse_75558_show_count( $content ) { $count = getPostViews( get_the_ID() ); … Read more
Here is a solution that uses genericons. The original code was derived from this question I asked, and answered by toscho, so credit goes to him for the original code that lead to the code in this answer. Check it out here First, download and intall the genericon pack in your theme. Enqueue the genericon … Read more
If you need to search by your meta_key/meta_value then do not store them in a single key. If you store as a single key then you are going to have to store your data as serialized string, or something similar. The only way you can search that would be via an inefficient %LIKE% query which … Read more
UPDATED ANSWER The correct function to use in context to WordPress and its intended API for this purpose is; esc_textarea Thus your code would reflect something like this; <textarea><?php echo esc_textarea($images);?></textarea> Although htmlspecialchars and htmlentities are valid to use, and even though esc_textarea wraps htmlspecialchars anyway, its more appropriate to use the official API call. … Read more
You have several options. XML-RPC http://codex.wordpress.org/XML-RPC_Support is the place to start. The API exposes a large number of methods to access WordPress data “outside” of the full WordPress context. Difficult to setup, connection requests overhead. wp-load.php Include wp-load.php to load up WordPress. You will need to chdir() into WordPress first for this to work properly, … Read more
Edit: It appears your actual problem is searching tags and categories, hence placing the s parameter inside the tax_query. There is no way to search tags categories and other terms using only the fields provided by WP_Query. Your query doesn’t work because what you want isn’t possible with just the parameters available. Instead of asking … Read more
This is doable, and as I stated in a comment, you need to follow the following steps Get a count the amount of sticky posts. This can be done by simply counting get_option( ‘sticky_posts’ ) which holds the ID’s of the sticky posts in the form of an array You would also need to get … Read more
get_the_content() return what’s in the editor, but wpautop filters and such are attached to the_content (which you don’t need inside your split function – just apply it later manually with apply_filters( ‘the_content’, $output ); at the end. You should as well use strip_shortcodes( get_the_content() ); before splitting it up: $output = get_the_content(); $output = wp_trim_words( … Read more
Whoa, ok let’s take a step back and use an actual WordPress function, that way your not doing anything weird like the above. Use these: http://codex.wordpress.org/Function_Reference/wp_get_attachment_image (the images) http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src (array with atributes) http://codex.wordpress.org/Function_Reference/the_post_thumbnail (featured image)