Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7433611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:41:56+00:00 2026-05-29T09:41:56+00:00

I’m trying to write a new plugin since I haven’t been able to find

  • 0

I’m trying to write a new plugin since I haven’t been able to find one that does exactly what I want with the extensibility that I desire. The goal of the plugin is to be able to use a simple shortcode to display an image slider that automatically populates with your blog’s latest posts.

I’ve got the basic plugin files ready and the shortcode implemented and tested. Now I’m trying to get the plugin to pull in the blog’s latest posts, but I’m running into a bit of a snafu. When I use the_title() and the_permalink() they display outside of the code I’m trying to contain them in. Further, the_content() is displaying once with the_permalink() and the_title() and then a second time where it’s supposed to.

You can see the behavior here.
Here’s the code I’m using:

function slyd( $category, $slydcount ) {
    global $post;
    $tmp_post = $post;  // Create $tmp_post to empty $post once Slyd is done with it

    $args = array(
        'category'    => $category,
        'numberposts' => $slydcount
    );
    $slydposts = get_posts( $args );
    foreach( $slydposts as $post ) : setup_postdata($post);
        $post_permalink = the_permalink();  // Get the post's permalink
        $post_title = the_title();          // Get the post's title
        $post_content = the_content();      // Get the post's content - will write code to get excerpt later
        return '<h2><a href="' . $post_permalink . '">' . $post_title . '</a></h2>\n'
        . '<p>' . $post_content . '</p>';
    endforeach;
    $post = $tmp_post;                      // Empty $post once Slyd is done with it
}

// Create the shortcode
function slyd_shortcode( $atts ) {
    // $atts        ::=        array of attributes
    // examples:               [slyd]
    //                         [slyd category='slide']
    //                         [slyd slydcount='5']
    //                         [slyd theme='default']

    /* Retrieve attributes set by the shortcode and set defaults for
       unregistered attributes. */
    extract( shortcode_atts( array(
        'category'   =>  '',        // Which category(s) to display posts from
        'slydcount'  =>  '5',       // How many Slyds to display
        'theme'      =>  'default'  // Which Slyd theme to use
    ), $atts ) );

    return "<p>category = {$category}, count = {$slydcount}</p>"
    . slyd( $category, $slydcount );
}

add_shortcode( 'slyd', 'slyd_shortcode' );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:41:57+00:00Added an answer on May 29, 2026 at 9:41 am

    By default, the_title will print out (echo) the title. You can pass extra parameters to the function in order to get it to just return the title, like so:

    <?php the_title('', '', false); ?> 
    

    But it’s even better to just use get_the_title instead – and the same goes for get_the_content and get_permalink as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.