Read more button not working

From the Codex: Excerpts (teasers) can be shown on WordPress through two methods: The first, keeping the the_content() template tag and inserting a quicktag called more at your desired “cut-off” point when editing the post. The second, by replacing the the_content() template tag with the_excerpt(). If one of those conditions is met, and you are … Read more

How to read a page’s “Shortcodes” from the Template File?

Parsing shortcodes from strings WordPress parses and replaces shortcodes from a piece of content via the do_shortcode function. This function, in turn, calls get_shortcode_regex, which returns the regular expression for matching shortcodes in a string. Using this function, we can get a list of all shortcodes ourselves: $pattern = get_shortcode_regex(); preg_match_all( “/$pattern/s”, $content, $matches ); … Read more

Make default template two columns?

1. Add .php in wp-content/themes/ Write <?php /** * Template Name: <subpage-name>, left sidebar * Description: A one-colum template with left sidebar for <subpage-name> ONLY */ get_header(); ?> 2. Copy full-width page basic codes. 3. Add new div for <div id=”main” class=”<subpage-name>-right clearfix” role=”main”> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( ‘content’, … Read more

Page.php vs Single.php

Edit Based on this comment: commenting out comments_template works. The problem lies in the template markup in comments.php. The likely reason that you see it in some output and not others is likely because you’ve got comments enabled in one context, and not in the other. Try comparing single posts with comments enabled vs disabled, … Read more

Display random page

The first condition you list is easy. You just need the post_parent__in arguments. $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => 1, ‘orderby’ => ‘rand’, ‘post_parent__in’ => array(2,169), // replace with your IDs ); $rand = new WP_Query($args); if ($rand->have_posts()) { while ($rand->have_posts()) { $rand->the_post(); the_title(); echo ‘<br>’; } } For the second condition, I … Read more

Problem retrieving custom field for a custom post type

The solution is simple: in the first loop, you are setting the $amazon_link like this: $amazon_link = get_field(‘amazon_link’, $image[‘ID’]); but in the second loop, you are setting a $link, like this: $link = get_field(‘amazon_link’, $image[‘ID’]); but you’re still trying to echo $amazon_link variable later on, which has never been setup in the second loop, so … Read more

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