Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter aputt

    (@aputt)

    Hey there,
    I came back to this issue and discovered a couple of problems with the code, finally being able to resolve this issue with your help.

    1. You were correct, tag was coming back as raom-loba, but the title as Raom & Loba. So, I had to sanitize the title.
    2. You were also correct in regards to the query format. I’ve adjusted the code in to reflect this change.
    3. You suggested using ‘terms’, but that refers to taxonomy and what I needed was ‘tag’. This is a great website for explaining the possible query references.

    In the end, the code comes back as such:

    <?php
    $title = get_the_title();
    $titlesan = sanitize_title($title);
    $args = array(
    'tag' => $titlesan,
    'posts_per_page'=>5,
    'category__not_in'=>array(19,20)
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    Content here
    
    <?php
    endwhile;
    }
    wp_reset_query();
    ?>

    Thread Starter aputt

    (@aputt)

    Thanks, I tried what you suggested, but it’s not working. I even tried other tags that were consistent in various posts that were single words, but they didn’t work either. I also tried adding a taxonomy of post__not_in for the category where the posts are, but it continues to only show the current post and not other posts with the same tag. No idea what could be happening.

    As a reference, I’m using WPML, but that shouldn’t affect this issue. In fact, usually if I put one category to call from, it recognizes the other category in the other language as well. In this case, I have it calling the category from both languages.

    Thread Starter aputt

    (@aputt)

    Yes, that is the case. The page’s address converts to Raom-Loba, but the tag uses &. You can see this below the text where it lists the tags associated with the page.

    Thread Starter aputt

    (@aputt)

    That’s exactly it. I have multiple posts that have the same tag and in the posts from one category, I want to show all the other categories (minus the one that your in presently).

    This is the post that I’ve created that currently uses your code:
    http://www.galeriamu.com/raom-loba-2/
    The posts listed under Exhibitions, Ediciones, Revista should be the other posts that have the tag of this post’s title.

    Thread Starter aputt

    (@aputt)

    Thanks for the reply. I’ve been playing around with your direction, and it makes sense, but it’s not working for me. It’s only calling the current post’s title and not using that title to identify the tags in other posts.

    Just as a reference, I cleaned up the code a bit. Any help would be appreciated.

    <?php
    $title = get_the_title();
    $args = array(
        'category__in' => array('10,12,21,22'),
        'terms' => $title
    );
    $the_query = new WP_Query( $args ); ?>
    <?php if ( $the_query->have_posts() ) : the_post(); ?>
    Content here
    <?php endif; ?>

    Agreed with esmi. After creating the child theme, you want to edit your index.php file for the home page or the content-single.php for your post loops.

    Place the_time function before the title function in your loop.

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php the_time('j F, Y') ?>
    <?php the_title(); ?>
    <?php the_content(); ?>
    <?php endwhile; endif; ?>

    Checkout the loop functions here:
    https://codex.ww.wp.xz.cn/The_Loop

    And the time function here:
    http://codex.ww.wp.xz.cn/Function_Reference/the_time

    When I have issues with adding new image sizes, I find that it doesn’t work on images that have already been uploaded. You have to reupload the image for it to recognize it due to WordPress cropping and saving a copy of the image when it uploads and not during the process of calling it to the page.

    Thread Starter aputt

    (@aputt)

    So far, I’ve gotten to the point of showing the current and sibling categories. Still need to apply the link to the first post.

    <ul style="list-style:none;">
    	<?php
    	foreach($category as $cat)
    	{
    		if($cat->category_parent!='0')
    		{
    
    			$this_category = wp_list_categories('orderby=id&hide_empty=0&title_li=&child_of='.$cat->category_parent."&echo=0");
    			//echo "<pre>";print_r($this_category);die("hhhhh");
    		}
    
    		?>
    			<?php
    			if($cat->category_parent=='0') {
    			?>
    			<li><?php echo get_cat_name($cat->cat_ID);?>
    			<?php } ?>
    			<li>
    			<?php   if($this_category && $cat->category_parent!='0') { ?>
    			<ul style="list-style:none;">
    			<?php echo $this_category;?>
    			</ul>
    			<?php } ?>
    			</li>
    	<?php }
    	?>
    
    </ul>
Viewing 9 replies - 1 through 9 (of 9 total)