Php code error in wordpress if else statements [closed]

You have multiple syntax errors in your code, see comments in below code: Code: <?php $googleplay = get_option(‘director_googleplay’); ?> <?php if( $googleplay ) : ?> // use echo not print <a href=”https://wordpress.stackexchange.com/questions/133771/<?php echo $googleplay; ?>”> // rework your src/IMAGES statement // is this a constant/variable? <img src=”<?php echo IMAGES; ?>/googleplay.png” class=” img-responsive top-buffer-5″ alt=”Image”/> // … Read more

Can’t get the previous and next posts permalink

You could use different code. As an example, this modified code from the Twenty Fourteen parent theme which i tested on other themes works well. Add this to a new file named template-tags.php <?php if ( ! function_exists( ‘wpsites_post_nav’ ) ) : function wpsites_post_nav() { $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : … Read more

List all anchor links on a page

In short, you’ll run the loop twice. The first time creating the links. The second time creating the posts. The trick is to figure out what the ID will be for the post. It needs to be something unique: We could use the slug or the post ID. <?php // I’m going to get the … Read more

Problem with multiple loops in wordpress theme

The proper way to set up a secondary query, using your example code. Instead of this: $posts = get_posts(‘numberposts=1&order=DESC&orderby=post_date&category=’.get_cat_ID( ‘سیاست’ )); Do this: // Query args $custom_cat_args = array( ‘posts_per_page’ => 1, ‘order’ => ‘DESC’, ‘orderby’ => ‘post_date’, ‘cat’ => get_cat_ID( ‘سیاست’ ) ); // Instantiate query $custom_cat_query = new WP_Query( $custom_cat_args ); // Instantiate … Read more

filter a loop base on specific category

There’s no valid query argument – category, it could be category_name or cat. So for your query, you can use – $custom_cat_args = array( ‘posts_per_page’ => 15, ‘order’ => ‘DESC’, ‘orderby’ => ‘post_date’, ‘cat’ => get_cat_ID( ‘سیاست’ ) ); Or $custom_cat_args = array( ‘posts_per_page’ => 15, ‘order’ => ‘DESC’, ‘orderby’ => ‘post_date’, ‘category_name’ => ‘سیاست’ … Read more

Style first 3 posts differently with WP_Query [duplicate]

You just need one more else statement, that’s it. <?php $lifestyle_cat = array( ‘category_name’ => ‘lifestyle’, ‘showposts’ => 3, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ); $lifestyle_query = new WP_Query( $lifestyle_cat ); if ( $lifestyle_query->have_posts()) { $i = 0; while ( $lifestyle_query->have_posts()) { $i++; $lifestyle_query->the_post(); if ($i==1) { // … Read more