![]() ![]() Lines 46-58 register all the shortcode’s information.Lines 43-44 check to make sure the function is defined (confirming the plugin is active), and if not it returns early.Line 28 builds the output, creating a link to the page, adding the styles defined above, and adds the page title.Line 27 checks if the page has a featured image, and if it does it sets the background-image equal to the featured image’s URL using the ‘page_link’ image size.If there are IDs passed, lines 23-31 build the shortcode output.Lines 18-22 define the parameter I’m expecting (ids) and ensures only integers are used. The first function creates the shortcode.Here’s a walkthrough of what’s happening: 'query' => array( 'post_type' => 'page'),Īdd_action( 'init', 'be_page_link_shortcode_ui' ) Īdd_image_size( 'page_link', 470, 300, true ) Īdd_action( 'after_setup_theme', 'be_page_link_image_size' ) 'listItemImage' => 'dashicons-admin-links', Shortcode_ui_register_for_shortcode( 'page-link', array( If( ! function_exists( 'shortcode_ui_register_for_shortcode' ) ) '' Īdd_shortcode( 'page-link', 'be_page_link_shortcode' ) wp_get_attachment_image_url( get_post_thumbnail_id( $id ), 'page_link' ). $style = has_post_thumbnail( $id ) ? ' style="background-image: url('. $ids = array_map( 'intval', explode( ',', $atts ) ) In my core functionality plugin, I placed the following to both register the shortcode and add it to Shortcake (walkthrough of the code follows the snippet). But the client won’t know the IDs for the pages, and will most likely forget the proper syntax for the shortcode (is it page-link, page-links, page_link, page_links… should I use id if I’m only linking to one page…). I created a simple shortcode that creates these links. Each page link will be a rectangle with the page’s featured image in the background and the page title overlaid. The client needs to be able to select which pages to include, and where to place it in the page’s content. I’m working on a website right now that includes visual page links in the content area. Here are recent chat summaries about Shortcake on the Make WordPress Core blog. It’s a core feature plugin, so hopefully it will be merged into WordPress core soon. Even better, if you’re in Visual mode it will render the shortcode for you! ![]() You get a nice visual builder, and when you click “Insert” it adds the properly formatted shortcode to your post. You click the “Add Media” button and there’s now a “Insert Post Element” option. All shortcodes that have included Shortcode UI code are displayed here. Shortcake provides a UI for inserting and viewing shortcodes in the editor. This issue can be minimized by registering your shortcode in a Core Functionality plugin and telling the client never to deactivate that plugin. A shortcode doesn’t visually represent what it will be on the frontend – it’s just text, and the client has to preview the page to see what it actually looks like.įinally, if the theme or plugin is ever deactivated, you’re left with content polluted with unused shortcodes. They are code, so most clients aren’t comfortable with it. I create custom metaboxes for managing page elements that are outside the main content area, like page-specific header and testimonials.I create a Style Guide page that shows all the styling options they have in the visual editor.I add additional styles to the visual editor if needed, so they don’t have to remember class names (ex: two different types of blockquotes).I use editor styles so that the Visual Editor in the backend matches the styles of the frontend.They can refer back to this in the future regarding custom features I built for them, since they won’t be covered in the videos. I provide detailed notes describing how to manage every aspect of their website when the site is sent for review.WP101 Video Tutorials to educate on how WordPress works and explain new features, because they’re always kept up-to-date with WordPress releases.There are a lot of tools I use to keep my websites as easy as possible for non-technical clients. You don’t need a developer on staff to update your website. The real value in a WordPress-based website should be ease of management. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |