$post_title
This topic contains 7 replies, has 2 voices, and was last updated by Paolo 8 years, 9 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: package_id
-
AuthorPosts
-
April 7, 2016 at 2:51 pm #159434
Is the post title stored somewhere where I could use it inside my functions.php?
Here is what I’m trying to do. I’m trying to set a variable with the post_tile then I’m looking for all posts tagged with the variable. Here is my function.
function posts_by_dir_tag(){ $content_tag = $post_title; $second_query = new WP_Query( array( 'tag_slug__in' => array( $content_tag ) ) ); // The Loop while( $second_query->have_posts() ) : $second_query->the_post();?> <a href="<?php the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php endwhile; wp_reset_postdata(); } add_action ('geodir_article_close','posts_by_dir_tag');
April 7, 2016 at 3:37 pm #159508I think I actually got it working with:
function posts_by_dir_tag(){ if (geodir_is_geodir_page()) { $post_title = the_title(); $second_query = new WP_Query( array( 'tag_slug__in' => array( $post_title ) ) ); // The Loop while( $second_query->have_posts() ) : $second_query->the_post();?> <a href="<?php the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php endwhile; wp_reset_postdata(); }} add_action ('geodir_article_close','posts_by_dir_tag');
April 7, 2016 at 3:40 pm #159510Nevermind it’s not working after all.
April 7, 2016 at 3:45 pm #159511Okay NOW I think I have it working.
//Add tagged content function posts_by_dir_tag(){ if (geodir_is_geodir_page()) { $post_tag = get_the_title($post->post_title ); $second_query = new WP_Query( array( 'tag_slug__in' => array( $post_tag) ) ); } // The Loop while( $second_query->have_posts() ) : $second_query->the_post();?> <a href="<?php the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php endwhile; wp_reset_postdata(); } add_action ('geodir_article_close','posts_by_dir_tag');
April 7, 2016 at 4:28 pm #159527The one thing I can’t seem to figure out is how to show this if they are package_id = 2 or is_featured.
April 7, 2016 at 6:47 pm #159618I’m trying to get the package_id here so I can only display posts if they are paid members but for the life of me I can’t seem to get the package id. I don’t know what I’m doing wrong.
//Add tagged content function posts_by_dir_tag(){ $post_tag = get_the_title($post->post_title ); $price_details = geodir_get_post_meta($post_id, 'package_id'); echo $price_details; $second_query = new WP_Query( array( 'tag_slug__in' => array( $post_tag) ) ); // The Loop while( $second_query->have_posts() ) : $second_query->the_post();?> <a href="<?php the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php endwhile; wp_reset_postdata(); } add_action ('geodir_after_main_content', 'posts_by_dir_tag');
April 7, 2016 at 7:51 pm #159644Ok I figured it okay. I hope you don’t mind me posting me solutions. Hopefully they can help someone else in the future.
In listing-details.php I did the following conditional:
if (isset($post->is_featured) && $post->is_featured) { add_action ('geodir_after_main_content', 'posts_by_dir_tag'); }
then in my own functions.php here is that function:
//Add tagged content function posts_by_dir_tag(){ $post_tag = get_the_title($post->post_title); if (isset($post->is_featured) && $post->is_featured) { echo 'featured'; } $second_query = new WP_Query( array( 'tag_slug__in' => array( $post_tag) ) ); // The Loop while( $second_query->have_posts() ) : $second_query->the_post();?> <a href="<?php the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php endwhile; wp_reset_postdata(); } add_action ('posts_by_dir_tag');
it seems to be working.
April 7, 2016 at 8:51 pm #159697Not at all, thanks for sharing! 🙂
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket