New Posts
Welcome guest, is this your first visit?
  • Login:
Affactive.com Affiliate Program
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Brazilian Barbecue Master
    My Status
     
    ----
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Brazil
    Posts
    303
    Feedback Score
    4 (100%)

    Default Help with wordpress code, php

    Hello friends!

    I had to ask you this because I cant find the answer anywhere and it is interesting.

    Basically I want to list recent articles from a tag, but the tag would be dynamic (the title of the post).

    For example, the post "Red Roses" would have a code to show recent articles with the tag "red roses".

    I tried to do that but I could not put the call for "post title" inside the php of the recent posts.

    Can you suggest something for me?

    Thanks!
    Professional translation: English to Portuguese. Native-speakers with experience in gambling.

  2. #2
    Senior Member
    ++ WhatCulture.com ++
     
    ----
     

    Add as a friend
    Join Date
    Aug 2010
    Location
    UK
    Posts
    343
    Feedback Score
    5 (100%)

    Default

    I know what you need to do, but I'm not technically minded enough to do it for you.

    The reason it won't work "out of the box", so to speak, is that you need to convert the spaces in the_title(); to be -'s.

    i.e. your query post will need to be something along these lines:

    PHP Code:
    query_posts"tag=".$convertedtitle ); 
    Before you do your query posts though, you'll need to do something like this (in proper code).

    PHP Code:
    $convertedtitle convert ' ' in the_title(); to '-' 

  3. #3
    Senior Member
    My Status
     
    ----
     

    Add as a friend
    Join Date
    Jul 2010
    Location
    Where u wanna B
    Posts
    156
    Feedback Score
    0

    Default

    That's a basic "related posts" query by tag.

    Search for wp_query related posts by tag and you'll find the code you want.

  4. #4
    Senior Member
    ++ WhatCulture.com ++
     
    ----
     

    Add as a friend
    Join Date
    Aug 2010
    Location
    UK
    Posts
    343
    Feedback Score
    5 (100%)

    Default

    It's not as basic as that, since he needs to use the title of the current post in the tag query.

  5. #5
    #!/usr/bin/mikebrad
    My Status
     
    ----
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    USA
    Posts
    912
    Feedback Score
    10 (100%)

    Default

    instead of "the_title()", you probably need to use "get_the_title()"

  6. #6
    Senior Member
    My Status
     
    ----
     

    Add as a friend
    Join Date
    Jul 2010
    Location
    Where u wanna B
    Posts
    156
    Feedback Score
    0

    Default

    Its nearly worth going about this a different way I think

    Why not set up a custom field that automatically (programatically) gets entered with the "title tag" you want when you post.

    That way its a simple custom field wp_query and you don't need to mess around with trying to get the current title.

    PHP Code:
    <?php $your_custom_field get_post_meta($post->ID'your_custom_field'true); if($your_custom_field): ?>
            <?php echo $your_custom_field?>
            <ul>
            <?php $your_list get_posts('numberposts=-1&meta_key=series&orderby=date&order=ASC&meta_value='.$your_custom_field); foreach($your_list as $your_list):?>
                <li><?php if($your_list->ID != $post->ID): ?><a href ="<?php echo get_permalink($your_list->ID); ?>"><?php endif; echo $your_list->post_title?></a></li>
            <?php endforeach; ?>
            </ul>
    <?php endif; ?>

  7. #7
    Brazilian Barbecue Master
    My Status
     
    ----
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Brazil
    Posts
    303
    Feedback Score
    4 (100%)

    Default

    Excellent idea, race. Will try that. Thanks!
    Professional translation: English to Portuguese. Native-speakers with experience in gambling.


 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Powered by vBulletin® Version 4.1.5
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
SEO by vBSEO 3.6.0