Millennial Media PHP Setup ( Code Integration )

I would not put that code into the theme. Create a plugin with the following content: <?php /* Plugin Name: Millennial Media Ads */ add_action( ‘show_ads’, ‘mma_show_ads’ ); function mma_show_ads() { # copy your PHP code into this function. } In your theme choose the place where you want to show the ads and write: … Read more

Custom Post Types on Custom Categories

Let’s go. First, create your custom post type (products): add_action( ‘init’, ‘add_post_type_products’ ); function add_post_type_products() { $labels = array( ‘menu_name’ => _x(‘Products’, ‘your_text_domain’), // the menu name text. This string is the name to give menu items. Defaults to value of name ‘name’ => _x(‘Products’, ‘post type general name’, ‘your_text_domain’), // general name, usually plural. … Read more

Trying to WP_Query a category

You are using WP_Query incorrectly: you need to be calling the have_posts() and the_post() functions as methods of your $query variable: <?php if (have_posts()) : while (have_posts()) : the_post(); ?> Becomes: <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?> You should also call wp_reset_postdata(); after the query loop is finished. … Read more

How do i retrive a post from a custom post type

I’m not sure that I completely understand your question, but if you’re just looking for an array of movies that are of the type distributie, based on the ID of the current Loop object, this will do it: $args = array( ‘post_type’ => ‘movies’, ‘meta_key’ => ‘distributie’, ‘meta_value’ => get_the_ID() ) $get_distributie_movies = get_posts( $args … Read more

Get first category only and excluding one

Within the post loop you can do, $category = get_the_category(); if($category[0]->cat_name == “featured”) { //if first category in array is “featured”, get next category in line $name = $category[1]->cat_name; $cat_id = get_cat_ID( $name ); $link = get_category_link( $cat_id ); echo ‘<a href=”‘. esc_url( $link ) .'””>’. $name .'</a>’; } else { //get the first category … Read more

Custom message if tag returns empty results

I am concerned about one part of your description. You say the user sees a “blank” page. Is the page completely blank? If so, you have a fatal error somewhere and an empty tag Loop isn’t the problem. I am assuming you meant that the content is empty but otherwise the page loads fine. You … Read more