WordPress Redirects on Install

The problem was created by some code in the htaccess from root. So: To present exactly my configuration: I have – http://maindomain.org with file directly in the root of my hosting. I know this may not be a best practice and i’ll change this. Subdomain i was trying to set was in a folder which … Read more

Complex query and posts pagination

First of all, the post_nav_link() function is used to paginate the main query on home and archive pages. It does not work with custom queries (unless you hack the main query which I strongly discourage, it is the same as using query_posts then). To paginate your custom query, you need to use next_posts_link() previous_posts_link() which … Read more

Get post/page data outside the loop

You’re using non-existent variables in your function, $post_id, $post, $page. Use get_queried_object to get data from the current page. if( is_single() || is_page() ){ $this_page = get_queried_object(); $excerpt = get_post_field( ‘post_excerpt’, $this_page->ID ); }

How to check if a post exist?

You want to rethink this code… to begin with, as the number of entries grow, looping them all is a bad idea. Consider adding a meta_query argument to the WP_Query so you are not looping through every single entry in the future, but limiting the database retrieval instead. Mainly you want to get rid of … Read more

code suddenly appearing from my tempate second loop

Are you absolutely certain that you don’t accidentally have a closing php tag where you shouldn’t? – yes – turned out to be that I had <? rather than <?php – probably the new server was set differently – as per https://stackoverflow.com/questions/2185320/how-to-enable-php-short-tags

popular post weekly and monthly

These $args is what you need and you may also use that in query_posts(); $args = array( ‘post_type’ => array( ‘post’ ), ‘post_status’ => ‘publish’, ‘posts_per_page’ => 9, ‘cat’ => $link1, // try better variable name ‘meta_key’ => ‘post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘date_query’ => array( array( ‘after’ => ‘1 months ago’, ), … Read more

Transient loop issue

The reason it’s only storing the first post data is because you’re using the same transient name for each post. If you want to store multiple movie transients, you need unique names for each movie. Also, the way you’re getting the transient defeats the purpose of using transients. You want to first try to get … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)