Magenaut

Magenaut

A blog about Magento Development, Magento bug fixing, and more

Skip to content
Menu
  • Home
  • Notes
  • Tutorial
  • Bug fixing
  • Extension
  • Server
  • Q&A
  • About

Tag: conditional-content

Q&APosted onAugust 5, 2022August 5, 2022

How to check if the current page is at a specified path in the URL?

I have a page marked as the Posts page that lists most recent blog posts.

Read More
Q&APosted onAugust 3, 2022August 4, 2022

How do test if a post is a custom post type?

I am looking for a way to test if a post is a custom post type. For example, in, say, the sidebar I can put in code like this:

Read More
Q&APosted onAugust 3, 2022August 4, 2022

Enqueue Scripts / Styles when shortcode is present

What is the idea way to register/enqueue scripts and/or styles for use in plugins?

Read More
Q&APosted onAugust 3, 2022August 4, 2022

Exclude custom function content from certain pages

I have added a small custom function to display a little author bio blurb at the bottom of each blog entry in my functions.php file inside the current theme that I am using. So far so good, it is working great but I noticed that this function is being applied to every page, for example it is showing up at the bottom of my “Contact” page.

Read More
Q&APosted onAugust 3, 2022August 4, 2022

Loading scripts only if a particular shortcode or widget is present

I needed a way to filter a page/posts content before it was loaded so I could add scripts to the header if a specific shortcode was present. After much searching I came across this on http://wpengineer.com

Read More
Q&APosted onAugust 3, 2022August 4, 2022

Why isn’t is_page working when I put it in the functions.php file?

I have page called “Apple”, the page’s ID id 2533.

Read More
Q&APosted onAugust 2, 2022August 3, 2022

wp_enqueue_script adding conditional statement not working

This is the code im using in my functions file:

Read More
Q&APosted onAugust 1, 2022August 2, 2022

How can I determine if a post has an image attachment?

As far as I know, there’s not a simple function that will return true if a post has an attachment. With that in mind, what’s the best way to determine if a post has an attachment (or even better, has an image attachment)? I’m automatically inserting a shortcode on posts, but would like that to only happen if there is actually an image attached to the post.

Read More
Q&APosted onAugust 1, 2022August 2, 2022

Show content after the first and second paragraph

The function below is used to show certain content after the first paragraph. I would like to show ‘content X’ after the 1st paragraph and ‘content Y’ after 2nd paragraph.

Read More
Q&APosted onJuly 31, 2022August 1, 2022

How to conditionally enqueue a stylesheet only for a certain page(s)?

Before I get started, I want to acknowledge that there are some really good articles that are targeted at how to conditionally enqueue scripts based on page/post content.

Read More

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 141 other subscribers

Recent Comments

  • anonymous on Fix libwacom9 dependency issue when upgrade Debian
  • sreedhar on Fix libwacom9 dependency issue when upgrade Debian
  • saintnick on Fix libwacom9 dependency issue when upgrade Debian
  • ranafoul on Fix libwacom9 dependency issue when upgrade Debian
  • John Fro on UFW rule from a list of IPs

Tags

actions admin ajax bash block-editor categories command-line css custom-field custom-post-types custom-taxonomy customization database debian filters functions hooks images javascript linux loop menus multisite pagination permalinks php plugin-development plugins post-meta posts rest-api security shell shell-script shortcode templates theme-development themes uploads url-rewriting user-roles users woocommerce-offtopic wp-admin wp-query

© Magenaut - The Magento Astronaut