• Resolved soltanamir1

    (@soltanamir1)


    Hi everyone,

    I have a best which displays our products, and I have little section called “Related Products” at the bottom of the listed product. Refer to the following link: https://www.terraworldltd.com/storage/932.html

    My problem is that the links in the Related products section uses the “/?p=N” structure, which the actual permalink structure is “/%category%/%post_id%.html”. This issue only happenes in the “Related Products” section. Based on my research there is a problem with the coding of this section, which is the following:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I have to change the coding somehow that it uses the permalink structure of my website. But I have a trouble figuring it out. I really really appreciate it if you can help me with this.

Viewing 15 replies - 1 through 15 (of 25 total)
  • I am not sure if this is exactly right as I didn’t test the code.

    Try replacing this line:
    $productlink = $postval->guid;
    with this:
    $productlink = get_permalink($product_id);

    back up the file before you change it

    Thread Starter soltanamir1

    (@soltanamir1)

    hey, Thank you for your reply. I really appreciate it.

    I actually tried this solution but it didn’t resolve the issue. Do you have any other suggestions?

    What happened – nothing changed?

    If that is correct I suggest inserting some debugging code for a few minutes

    change this

    $product_id = $postval->ID;
    $product_post_title = $postval->post_title;
    $productlink = get_permalink($product_id);

    to this

    $product_id = $postval->ID;
    echo 'ID = '. $product_id. ' <br />';
    $product_post_title = $postval->post_title;
    echo 'permalink = '. get_permalink($product_id). ' <br />';
    $productlink = get_permalink($product_id);

    This will print two lines that will show the ID # on one line and the permalink on the next line, one set for each post. I can’t say where on the page it will print – depends on where it runs. You may have to look hard for it. What you are after is to see what the permalink printout looks like,

    The problem in your original code is it is using what is called the post GUI Id code, which contains the link formatting that you don’t want.

    If you are seeing no output of those lines I added you should make sure the right version (meaning the right file) of the code is getting executed – one source of “nothing changed” issues is that the changed code was never used by the program. If you are using a caching plugin make sure you are seeing the live page and not a cached copy.

    Thread Starter soltanamir1

    (@soltanamir1)

    hey the problem was actually the caching. As soon as I disabled it, it worked. It now uses my custom permalink structure. Thank you.

    But it didn’t resolve my initial issue, which I didn’t explain above. I thought by fixing the permalink, it would resolve the issue. Maybe if I explain it to you, you might be able to help me.

    I recently changed the directory of my wordpress site from https://www.TerraWorldLtd.com/wordpress to https://www.TerraWorldLtd.com. Everything works fine except the “Related Products” section.

    In this section, the thump image is not displayed ref: https://www.terraworldltd.com/laptop/13inch/164.html under Related products.
    But the new product entries under the new directory, shows the product thump as it should. ref:https://www.terraworldltd.com/storage/932.html under Related products.

    So the problem is that it doesn’t display the thumbs from the products entry in the old directory. I hope I explained my issue correctly. I spent days into resolving this issue, but still no luck. I really appreciate your help.

    I went to https://www.terraworldltd.com/laptop/13inch/164.html and I am seeing all the images on the page. I see thumbnails in related products and the full size images when I click the thumbnails.

    Am I not understanding something you are asking? If so please rephrase

    Thread Starter soltanamir1

    (@soltanamir1)

    I am not talking about the actual images of the product listed in that page. Those are fine. But if you look at the bottom of the page under Related Products, you see title of products which links to their actual page. It should display image thumb along with the title. Similar to https://www.terraworldltd.com/storage/932.html .

    Hope this time I explained correctly. ??

    Got it

    This is the Related products HTML the browser is seeing for the first item on storage/932.html

    <ul class="realated_products">
       <li>
          <a class="product_thumb" href="https://www.terraworldltd.com/storage/934.html">
             <img alt="TERRA THE MODULAR 2522 (BTO)" title="TERRA THE MODULAR 2522 (BTO)" src="https://www.terraworldltd.com/wp-content/themes/eshop/thumb.php?src=https://www.terraworldltd.com/wp-content/uploads/products_img/b1015828.jpg&w=130&zc=1&q=80">
           </a><a href="https://www.terraworldltd.com/storage/934.html">TERRA THE MODULAR 2522 (BTO)</a>
        </li>

    And this is what it is seeing on the other page for the 1st item:

    <ul class="realated_products">
      <a href="https://www.terraworldltd.com/laptop/13inch/168.html">Terra Mobile 1330 Pro</a>

    The LI tag is missing, the IMG tag is missing, and the second A tag is missing. I can’t tell from looking at that what happened to them.

    You changed the URL of your site. Are you sure that every single reference to https://www.TerraWorldLtd.com/wordpress was changed in your database to https://www.TerraWorldLtd.com ? There can be thousands of full path URL’s stored in a WP database. There are ways to make sure every last one has been changed to a new site URL. If that hasn’t been done on your site that could be the source of the missing image problem. What is eshop’s behavior when it can’t find an image it is looking for?

    Thread Starter soltanamir1

    (@soltanamir1)

    When eshop can’t find the image it is looking for is gives that famouse icon for image not found.

    I think I changed every single reference from the old directory to the new directory. But maybe you are right. Maybe I haven’t changed everything. How can I proceed further?

    The way I change them is using a PhpMyAdmin MySQL database dump.

    Going to PHPmyAdmin, click the database name in the left column (not the tables, the database name above the tables, and then do an Export.

    I use these settings:
    check
    Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT
    and Add IF NOT EXISTS
    remove check
    Extended inserts

    I export the entire database. Then open in text editor (use Windows Notepad if you don’t have a text editor (if you are on Windows that is) and search for the string TerraWorldLtd.com/wordpress anywhere in the file. If you find any, you know they need to be replaced.

    I change all the references to the old location I find in the dump file using search and replace, and import the revised file back into the database.

    Now, if you are not familiar with what I refer to, this is like brain surgery on the whole WP install, so if you have to change anything, make sure you keep an unchanged copy of the dump file so you can revert back to where the database is now if anything goes wrong.

    Thread Starter soltanamir1

    (@soltanamir1)

    Thanks for replying.

    I changed everything. It basically didn’t change anything. Do you think the problem could be from the actual code for Related products, stated above?

    Look at your older posts and see if the missing images are still associated with the posts. The code above skips over displaying the image if there are no associated images with a post. It also accounts for the code I wrote before that is missing since it writes no LI or IMG or first A tags when there are no images.

    Its possible you messed up the image connections to the posts when you moved the site. I don’t know if this is a plugin or whatever, so I don’t know how the images are getting associated with the posts in the first place. I would check to see if that connection has been messed up. That would explain why it works on newer posts

    Thread Starter soltanamir1

    (@soltanamir1)

    The missing images are still associated with the post. The images display everywhere in the product list even the “latest product” in the front page. The only place that doesn’t display is the “Related products”.

    ??

    Does that help??

    What is the source of the related products display? Is this a plugin? Is it part of Eshop? How do you associate related products with a product?

    Thread Starter soltanamir1

    (@soltanamir1)

    No its not a plugin. Its part of the eshop theme. Its a PHP file associated under includes folder, under the theme.

    If you need more info, let me know

    What eshop theme?

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Permalink’ is closed to new replies.