Categories and page filtering with pre_get_posts

Please Consider this snippets of code. <?php $myarticles = new WP_Query( ‘post_type=myarticles&orderby=date&order=DESC&cat=4’ ); while ($myarticles->have_posts()) : $myarticles->the_post(); $postTitle = get_the_title(); $postid = get_the_id(); $postContent = get_the_content(); ?> <li><p><?php echo $postTitle; ?></p> <a href=”#”><?php the_post_thumbnail(array(219,143)); ?></a> <p><?php echo $postContent; ?></p> </li> <?php endwhile; ?>

Custom fields: dropdown values depending on other custom field value

This is possible by using AJAX. The following links are containing more information about AJAX and implementation in WordPress: http://codex.wordpress.org/AJAX Ajax (Asynchronous JavaScript And XML) is a technology that allows a web page to perform actions or update dynamically, without completely reloading http://codex.wordpress.org/AJAX_in_Plugins This article, aimed at plugin developers, describes how to add Ajax http://wpmu.org/how-to-use-ajax-with-php-on-your-wp-site-without-a-plugin/ … Read more

short code output too early

A shortcode has to return just a string, you should not print something like in wp_list_pages() or echo. From Shortcode API: The return value of a shortcode handler function is inserted into the post content output in place of the shortcode macro. Remember to use return and not echo – anything that is echoed will … Read more

Top Contributors Plugin with Custom Post Type

This plugin hasn’t been updated in almost two years, so you should consider finding a new one. That said, in this cases you have to open1 the plugin files and search for some string related to your issue, e.g., post_type. You’ll find that in the file functions.inc.php, it has two occurrences of: AND a.post_type=”post” Change … Read more

Image attachement management – a philosophical question

WordPress doesn’t have the innate functionality to enumerate attachments as is. Although any attached images can be viewed in the Media Library. In the Media Library, you’ll notice the list of images that are attached to a post have that attribute under the “Uploaded to” column. In that column, lets say for example an image … Read more

wp_get_attachment_url not working

Add the PDF attachment ID as a custom field value, for example attached_pdf_id. Get the URL using wp_get_attachment_url(): <?php if ( is_user_logged_in() ) { $pdf_link = wp_get_attachment_url( get_post_meta( get_the_ID(), ‘attached_pdf_id’, true ) ); if ( $pdf_link ) { ?><a href = “https://wordpress.stackexchange.com/questions/89809/<?php echo $pdf_link ?>” >Download</a><?php } else { ?>Sorry, no link available. Please contact … Read more