• Resolved marekvbeek

    (@marekvbeek)


    Hello Devs,

    The reason I write you today is because I need help with displaying the secondary title ONLY on the single product page (WooCommerce) and not on the category page.

    I use the secondary title as a value proposition to my single product page. That doesn’t mean it should show the secondary title on the category page. I just want the regular title being displayed on the category page, and anywhere else.

    What can I do?

    The page I need help with: [log in to see the link]

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author thaikolja

    (@thaikolja)

    Hi @marekvbeek,

    You probably want to disable “Auto show” on the plugin’s options page. Then you have to display it manually via PHP. Do you need any assistance with that?

    Thread Starter marekvbeek

    (@marekvbeek)

    Hello Thaikolja,

    Thank you for your amazing quick reply.
    I think I figured that out as well. I’m not so handy to do that manually via PHP. Yes, could you assist with that?

    Also I used this code before to move the Product title up, may be important to notice:

    //* Move product title and reviews before single_product_summary *//
    
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
    add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 0 );
    Thread Starter marekvbeek

    (@marekvbeek)

    Hello @thaikolja,

    Do you have any suggestions moving forward?

    Kind regards,
    Marek

    Thread Starter marekvbeek

    (@marekvbeek)

    Hey hey @thaikolja ,

    I could still use your help with the PHP coding. Please let me know.

    Kind regards,
    Marek

    Thread Starter marekvbeek

    (@marekvbeek)

    Helloooooooooooo @thaikolja

    Plugin Author thaikolja

    (@thaikolja)

    Hi @marekvbeek,

    Please try this:

    add_action(
    	'get_secondary_title',
    	function ( $secondary_title ) {
    		if(is_singular() && is_product()) {
    			return $secondary_title;
    		}
    		else {
    			return '';
    		}
    	}
    );
    Thread Starter marekvbeek

    (@marekvbeek)

    Hi @thaikolja,

    Thank you for your reply.
    I’ve added the code to functions.php and this is what happens:
    The secondary won’t display. When I enter a secondary title in the back-end of the product and save it, it will remove the secondary title field leaving it blank.

    What can I do?

    Thank you for your help ??

    Plugin Author thaikolja

    (@thaikolja)

    You wanted it to not display on singular product pages, right? If it disappears from the admin area, use this:

    add_action(
    	'get_secondary_title',
    	function ( $secondary_title ) {
    		if(!is_admin() && is_singular() && is_product()) {
    			return $secondary_title;
    		}
    		else {
    			return '';
    		}
    	}
    );
    Thread Starter marekvbeek

    (@marekvbeek)

    @thaikolja unfortunately that isn’t working either. ??

    I want to display the secondary title only on the single product page.

    The code seems to automatically delete the secondary title from the backend, making it impossible to display it: After I fill in the field “Enter secondary title here” and save the product, the field becomes empty again. Not allowing me to save the secondary title.

    When I remove the code, I am able to save the secondary title again.

    • This reply was modified 3 years, 4 months ago by marekvbeek.
    • This reply was modified 3 years, 4 months ago by marekvbeek.
    Plugin Author thaikolja

    (@thaikolja)

    Okay, to clarify: You want the Secondary Title to be displayed only on single product pages?

    Thread Starter marekvbeek

    (@marekvbeek)

    Correct

    Plugin Author thaikolja

    (@thaikolja)

    Then it’s easier to turn off “Auto show” and to use <?php the_secondary_title(); ?> in the .php file that is being used for single product pages.

    Thread Starter marekvbeek

    (@marekvbeek)

    Hmm okay. How do I do that? I’m not very handy with that. I also use a child-theme so I can still receive theme updates. And if a product doesn’t have a secondary title, will still be the regular title displayed?

    Thanks a lot for your help!

    Plugin Author thaikolja

    (@thaikolja)

    You’d have to identify the file first. Unfortunately, I can’t tell you where it is because I don’t know your theme.

    If you still need help, please join my Slack channel.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Don’t want to display secondary title on category page’ is closed to new replies.