Did you know that you can use WordPress built-in “mobile detect” function wp_is_mobile to create a simple shortcode that can hide certain parts of your content from mobile visitors and-/or desktop visitors. The wp_is_mobile function returns true when your site is viewed from a mobile browser. Using this function you can create adaptive-/responsive wordpress themes …
Category: Code Snippets
To display the WordPress site(blog) name and description – you can add the following to your template. Related links https://developer.wordpress.org/reference/functions/bloginfo/
With the WordPress function: wp_get_attachment_image_src, you can get the src of the featured image. Instructions Add this code to your page/post template file where you want to use the featured image source.
Here is a snippet that will enable you to show a short intro (excerpt) of the author bio of a post and not the complete bio. With this snippet you can make an excerpt of the author bio, with a link to the author page, where you can see the full bio. Instructions Add this …
Sometimes you need to display post-specific content using custom fields. In this example we will show you how you can display custom field data using conditional statements in the form of a youtube video embed. If the post has a "youtube-video-link" defined, the content will be rendered.
If you only wish to show content only on the front page, you can do so by wrapping the content in a is_page (is_front_page) conditional statement. You can also choose to display content on all pages BUT front page by adding “!” to your statement. Instructions Insert content as shown below. Related Links: Source: …
Expose the Wordpress "img src" part from the get_the_post_thumbnail, to modify the "img src" syntax.
This snippet automatically sets the featured image by fetching the first image of the post.
Heres a little snippet that will display recent posts from a specific category.
This snippet will allow you to set custom excerpt lengths in your excerpt tag in your template. Instructions Add this code to your functions.php file. And then use this syntax to invoke your custom excerpt length in your template: