how to loop through blog posts in php

$args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ); $the_query = new WP_Query( $args ); If you set the posts_per_page to -1 it will return all posts. Then you can loop through and do what you want with the single post. while ( $the_query->have_posts() ) { echo get_the_author_meta( );//I have NOT used this so … Read more

Can’t modify plugin function

Child themes only let you override templates, but they don’t override other PHP files, e.g. anything included from functions.php. You can try to change things via hooks, but if the function provides no hooks then you’re stuck. There is no way to override it unless a way has been provided by the author of the … Read more

Please give me the rewrite rules for my ugly urls

if you are trying to get http://www.myblog.com/currentpage/1 http://www.myblog.com/currentpage/2 then your function should be add_action(‘generate_rewrite_rules’, ‘currentpage_rewrite_rule_222’); function currentpage_rewrite_rule_222($wp_rewrite){ $newrules = array(); $new_rules[‘currentpage/(\d*)$’] = ‘index.php?currentpage=$matches[1]’; $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } and just keep your query_vars function the way it is. add_filter(‘query_vars’, ‘wpa3537_query_vars’); function wpa3537_query_vars($query_vars) { $query_vars[] = ‘currentpage’; return $query_vars; }

Missing argument 2

You t2t_homepage_slide($slide,$size) function requires 2 arguments and your only calling it with one. Either include the $size argument when calling the function or remove the requirement or provide a default when defining the function (line 94). eg: function t2t_homepage_slide( $slide, $size=””) { <— line 94 global $wpdb; $image = get_option($slide); $caption = get_option($slide.’_caption’); $price = … Read more

WordPress: code structure

I find that very easily my views become cluttered with logic, e.g. null checks, email validation, and retrieving values from the post object. How would you separate this out in WordPress? Is there any sort of MVC framework? There is no clear separation enforced by WordPress and there is extremely wide range of styles and … Read more

Save output of the_content_rss into variable

the_content_rss() is deprecated. You should be using the_content_feed(), but that is a secondary problem. Both functions echo content. What you want is the get_* variant– get_the_content_feed(). That is a general rule, by the way, but not a 100% consistent one. Many functions starting with the_ will output content immediately and there tends to be a … Read more