WordPress.org

Forums

use a plugin's category slug to pull back posts specific to that plugin (1 post)

  1. martyn.ppsee
    Member
    Posted 10 months ago #

    Hello,

    I am a bit stuck trying to create a custom widget on a sidebar for retrieving information from a specific jobs plug-in. The widget can be hardcoded onto the sidebar, it's my only work around with this theme as the theme authors seem to have left out the normal sidebar widget area.

    I know the slug name and taxonomy but cannot seem to retrieve any data, for this example I am going to call the slug "featured-jobs".

    The php I am using is below, I am simply trying to get the post titles and excerpts for the moment in a list as a proof of concept to style later but I am not sure what I have missed or where my error is:

    <?php
    global $post;
    $args = array( 'numberposts' => 5, 'category_name' => 'featured-jobs' );
    $posts = get_posts( $args );
    foreach( $posts as $post ): setup_postdata($post); 
    
    echo "<div>";
    echo "<?php the_title() ?>";
    echo "<?php the_excerpt() ?>";
    echo "</div>";
    
    endforeach;
    ?>

Reply

You must log in to post.

About this Topic

  • RSS feed for this topic
  • Started 10 months ago by martyn.ppsee
  • This topic is not resolved
  • WordPress version: 3.9.1