How to go to a page to edit

Author Posts

robertlo

Is there a way to go directly to a URL on a page to edit certain elements of it that may only exist on that page?


Sebastian

Hi Robert,

Yes, you can enter a custom URL via the preferences in the left toolbar and Microthemer will then go to that page. A few people miss this option it seems. I’m currently pondering whether their should be an option for entering a custom url more easily that would reload the preview page immediately. Just not sure where this would go at moment…

Does that answer your question though? At first I thought you might be asking if it’s possible to create styles that apply to just one page, even if the element appears on different pages. It is, but requires prepending the selector code with page ids e.g.

.page-id-45 .my-selector

This requires that your theme inserts page ids in the body class attribute (many do).

Cheers,
Sebastian

ps the selector wizard will have some variation options in a future release that will make individual page targeting (and targeting in general) much easier.


robertlo

Sebastian,

Sounds good. And yes I was just asking how to go to a specific page in MT. For page specific css, I’ve always use a the Add to Head plugin, as it lets you add any code to the head of any page or post (and most any post type). But if I can do that in MT, I’d rather do it there to keep all custom css in one place.


Sebastian

Great, you’ll like the new selector wizard when we roll that out then. It will have variation options for automatically prepending selectors with page IDs etc, or appending pseudo selectors like :hover, :nth-of-type etc.


robertlo

Hmm. I used .page-id-9 .my-selector to prepend the MT CSS, which made it

.page-id-9 .my-selector main#main img.wp-post-image

Behavior set to none, but that brought the images back, instead of hiding them as they were with only main#main img.wp-post-image , which I don’t want to use because they hides the product image from all pages, even the individual product pages. I only want to hide it from shop pages.

The theme is WooCommerce’s general StoreFront theme, so since prepending the selector code with .page-id-9 .my-selector actually caused the product images to display again, does that mean the theme doesn’t inserts page ids in the body class attribute?

However, I did find the code to do hide product images in the shop page in functions.php

remove_action( ‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_template_loop_product_thumbnail’, 10 );

However, this is a multisite, and it looks like the changes I apply to functions.php are applying network-wide, which I think is something I’m doing wrong on my end. I’d rather hide the product images on shop pages with with php instead of CSS…..if I can. But I need that edit to be applied per site in my multisite network, not to all sites in the network.

But until I figure that out, if you can help me do that with MT, that would be great. If not, I can just put the css in that page using the Per Page Head plugin, but I like to keep my plugins to a minimum.

Any thoughts?


Sebastian

Hi Robert,

I must apologise. I wasn’t clear enough that .page-id-45 .my-selector was just an example and not actually a valid CSS selector. I would need to have a look at your site (specifically the page you’re referring to), but then I should be able to provide you with a real selector that hides the images.

Could you post a link to your site here or send it via our contact form?

https://themeover.com/support/contact/

Cheers,
Sebastian


robertlo

I also tried .page-id-9 main#main img.wp-post-image as the page ID is 9 for this page, but that didn’t work either.

Here’s the page I want to hide product images for. It’s the main WooCommerce shop page.

http://preachnet.com/freeindeed/sermons/


Abland

Hi, robertlo,

Maybe try this in your theme’s functions.php

global $blog_id;
if ($blog_id == 2): // use your blog id
remove_action( ‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_template_loop_product_thumbnail’, 10 );
endif;

I use blog ids one at a time because I couldn’t get an array to work – so for multiple blogs to remove thumbnails use:
if ($blog_id == 2 || $blog_id == 3 || $blog_id == 4): //etc...


Sebastian

Thanks for catching this Abland. And sorry for the delay in responding Robert.

Unfortunately your theme doesn’t seem to insert page-ids in the body class. So I would recommend Abland’s solution as you wanted to switch off the images more than hide them with CSS anyway. Have you had much luck with the code Abland provided?

Cheers,
Sebastian

ps If you only want the images to be removed on one page (with page id 9) you might try this instead:

global $blog_id;
if ( $blog_id == 2 and is_page( 9 )  ): // use your blog id
remove_action( ‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_template_loop_product_thumbnail’, 10 );
endif;

You must login or register to reply to this topic.