use loop to return blog details

You need to re-arrange your code. <?php $post_id = 20; while($post_id <= 25) { $queried_post = get_post($post_id); $author_id = $queried_post->post_author; echo get_the_author_meta(‘display_name’, $author_id); $post_id++; } ?> Within while loop above you have $queried_post which is an object of class WP_Post. Member Variables of WP_Post can be used to display data about each post. I hope … Read more

trying to get wp_get_attachment_url to output clickable link

You’re onto the answer… The function, wp_get_attachment_url() (see Codex) just gives you the URL. You could wrap it in a link: echo ‘<tr><td><a href=”‘ . esc_attr(wp_get_attachment_url($row[‘item_code1’])) . ‘”>’ . esc_html($item_1_title) . ‘</a></td></tr>’; Alternately, you can use wp_get_attachment_link() (see Codex) as you mentioned: echo wp_get_attachment_link($row[‘item_code1’], ‘medium’, false, false, esc_html($item_1_title)); Neither is specifically better all the time, … Read more

Shortcode for Listing Users from Meta Value?

It’s a small coding mistake.. It’s not displaying anything because when there are results, the end output is always a </ul> because you’re always overwriting the $results and not appending output to the variable: $results=”<ul>”; foreach ($users as $user){ $results=”<li>” . $user->display_name . ‘</li>’; } $results=”</ul>”; So the proper code is: $results=”<ul>”; foreach ($users as … Read more

wp_nav_menu not working correctly in my underscores theme

If found out that this is removing my menu: function add_menu_icon ( $items, $args ) { if ( $args->theme_location == ‘primary’ ) { $elements=”<li class=”custom-logo”>” . get_custom_logo() . ‘</li>’; $elements .= $items; $items = $elements; return $items; } } add_filter( ‘wp_nav_menu_items’, ‘add_menu_icon’, 10, 2 ); I still haven’t figured out why.

Handling PHP/HTML inside the output of a shortcode function

This is mostly working fine. You probably want quotes around your id in the window.superformIds array to ensure it’s a string. This is a bad way of going about this. With scripts and styles you want to avoid outputting them directly on the page wherever the shortcode is placed. Here’s a better method: add_action( ‘wp_enqueue_scripts’, … Read more

php preg_match with multiple patterns

I think this is what you are looking for if (preg_match(‘@^/((?!blog|tag)[^/]+)/(?:page/)?\d+@’, $_SERVER[‘REQUEST_URI’], $m)) { wp_redirect(“/$m[1]”, 301); } The regexp uses lookahead to make sure that the first match isn’t blog or tag. The ‘[^/]+’ part matches anything that isn’t a forward slash (/). (?:page/)? – Makes an optional match against ‘page/’ \d+ – Match against … Read more

How can I find the cause of a 500 server error?

Okay, here’s what I did. If this happens, hopefully this will work favourably for you. If this is disabled by default, enable wp-debug by changing the value from false to true. Check that you have enabled WP_DEBUG_LOG and WP_LOG_DISPLAY. Try refreshing the page and see what happens. Either using WinSCP or the terminal, go to … Read more