PHP if to remove div (6 posts)

  1. WeirdMike
    Posted 3 years ago #

    I would like to remove a featured image I have called inside of a div without a name on ALL of my MarketPress pages on my site but allow it everywhere else.

    Is there a condition tag to hide the div with any url slug that contains /store?

    If so, how can this be done?

    (a breakdown of the code would be grand for learning if I need it in the future)

  2. WeirdMike
    Posted 3 years ago #

    This is what's happening when I attach a featured image to my product (which I need for the main product page to show the thumbnail)


    What it looks like elsewhere on the site
    (images haven't been updated)


    What I want things to look like in the /store


  3. Andrew
    Forum moderator
    Posted 3 years ago #

    Need you use PHP, opposing CSS?

  4. WeirdMike
    Posted 3 years ago #

    I could use display none but that doesn't help in using conditional tags.

  5. Alekie
    Posted 3 years ago #

    I used this once in my template and it worked out well for me. I would retrieve the page name or post name and decide based on this what to show...

    $pageslug = $post->post_name; // name of the page (slug) or post
    $catslug = get_category_by_slug($pageslug); // get category of the same slug
    $catid = $catslug->term_id;  // get id of this category
    $query= 'cat=' . $catid. ''; //Get the cat
    query_posts($query); // run a query if you so wish
    //For example here am testing for the contact us page - can't recall if it worked with default or pretty permalinks may be try both
    //this can also test for $catslug i.e category
    if (!($pageslug == "contact-us")){
    //Do my stuff here based on the slug test
  6. WeirdMike
    Posted 3 years ago #

    I will try this in the morning and let you know how it worked. Hopefully MarketPress uses "store" as a category and not just a dir link

Topic Closed

This topic has been closed to new replies.

About this Topic