{"id":22651,"date":"2016-08-05T11:36:14","date_gmt":"2016-08-05T11:36:14","guid":{"rendered":"https:\/\/wpgeodirectory.com\/docs\/?p=22651"},"modified":"2016-08-05T13:36:28","modified_gmt":"2016-08-05T13:36:28","slug":"moving-videos-to-the-sidebar-of-the-detail-page","status":"publish","type":"post","link":"https:\/\/wpgeodirectory.com\/docs\/moving-videos-to-the-sidebar-of-the-detail-page\/","title":{"rendered":"Moving videos to the sidebar of the detail page"},"content":{"rendered":"<h3>Introduction<\/h3>\n<ol>\n<li>One of the standard custom fields is a video field where you or your users can add a YouTube video to a listing.<\/li>\n<li>That video then will show on the detail page in the content section of the listing.<\/li>\n<li>This article explains how you can move the video from the content section to the sidebar.<\/li>\n<\/ol>\n<h4>Before:<\/h4>\n<p><img loading=\"lazy\" class=\"greenborder\" src=\"https:\/\/wpgeodirectory.com\/docs\/wp-content\/uploads\/sites\/3\/2016\/08\/tips16.png\" alt=\"\" width=\"700\" height=\"334\" \/><\/p>\n<h4>After:<\/h4>\n<p><img loading=\"lazy\" class=\"greenborder\" src=\"https:\/\/wpgeodirectory.com\/docs\/wp-content\/uploads\/sites\/3\/2016\/08\/tips15.png\" alt=\"\" width=\"700\" height=\"286\" \/><\/p>\n<h3>Step 1: Install Code Snippets plugin<\/h3>\n<ol>\n<li>You can add the code below to your child theme&#8217;s <em><strong>functions.php<\/strong><\/em> file as well, but using the <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" target=\"_blank\">Code Snippets plugin<\/a> makes it easier to keep track of the code, and it will be less likely the code is overwritten by a theme update.<\/li>\n<\/ol>\n<h3>Step 2: Code<\/h3>\n<p>Add a new code snippet, and copy and paste the following code:<\/p>\n<p>[php]<br \/>\nadd_filter(&#8216;geodir_detail_page_tab_is_display&#8217;, &#8216;custom_gd_hide_video_tab&#8217;, 10, 2);<br \/>\nfunction custom_gd_hide_video_tab($value, $tab) {<br \/>\n    if ($tab == &#8216;post_video&#8217;) {<br \/>\n        $value = false;<br \/>\n    }<br \/>\n    return $value;<br \/>\n}<\/p>\n<p>add_action(&#8216;geodir_detail_sidebar_inside&#8217;, &#8216;custom_gd_show_video_in_sidebar&#8217;, 1);<br \/>\nfunction custom_gd_show_video_in_sidebar() {<br \/>\n    global $post;<br \/>\n    $video = &#8221;;<br \/>\n    if (geodir_is_page(&#8216;preview&#8217;)) {<br \/>\n        $video = isset($post-&gt;geodir_video) ? $post-&gt;geodir_video : &#8221;;<br \/>\n    } elseif (geodir_is_page(&#8216;detail&#8217;)) {<br \/>\n        $video = geodir_get_video($post-&gt;ID);<br \/>\n    }<br \/>\n    if ($video != &#8221;) {<br \/>\n        echo &#8216;&lt;div class=&quot;geodir-video-wrapper&quot;&gt;&#8217;;<br \/>\n        echo wp_oembed_get(stripslashes($video));<br \/>\n        echo &#8216;&lt;\/div&gt;&#8217;;<br \/>\n    }<br \/>\n}<\/p>\n<p>add_action(&#8216;wp_head&#8217;, &#8216;custom_video_responsive_css&#8217;);<br \/>\nfunction custom_video_responsive_css() {<br \/>\n    if (geodir_is_page(&#8216;preview&#8217;) || geodir_is_page(&#8216;detail&#8217;)) {<br \/>\n        ?&gt;<br \/>\n        &lt;style type=&quot;text\/css&quot;&gt;<br \/>\n            .geodir-video-wrapper {<br \/>\n                margin-top: 20px;<br \/>\n                position: relative;<br \/>\n                padding-bottom: 56.25%; \/* 16:9 *\/<br \/>\n                padding-top: 25px;<br \/>\n                height: 0;<br \/>\n                margin-bottom: 10px;<br \/>\n            }<\/p>\n<p>            .geodir-video-wrapper iframe {<br \/>\n                position: absolute;<br \/>\n                top: 0;<br \/>\n                left: 0;<br \/>\n                width: 100%;<br \/>\n                height: 100%;<br \/>\n            }<br \/>\n        &lt;\/style&gt;<br \/>\n        &lt;?php<br \/>\n    }<br \/>\n}<br \/>\n[\/php]<\/p>\n<p><i class=\"fa fa-exclamation-triangle fa-2x\" style=\"color: red;\"><\/i> <span style=\"color: #ff0000;\">Make sure you activate the snippet when using the Code Snippets plugin.<\/span><\/p>\n<h3>Step 3: Adding video link<\/h3>\n<p><i class=\"fa fa-exclamation-triangle fa-2x\" style=\"color: red;\"><\/i> When adding the video link, only add the link to the video. For example:<\/p>\n<p>[html]https:\/\/www.youtube.com\/watch?v=rxgWHzMvXOY[\/html]<\/p>\n<h3><a id=\"tip\"><\/a>Step 4: Add a tip for your users<\/h3>\n<p>You can add a description to the video field at <strong><em>GD &gt; Place Settings &gt; Custom fields &gt; Video field<\/em><\/strong>:<br \/>\n<img class=\"greenborder\" src=\"https:\/\/wpgeodirectory.com\/docs\/wp-content\/uploads\/sites\/3\/2016\/08\/tips17.png\" alt=\"\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the standard custom fields is a video field where you or your users can add a YouTube video to a listing.<br \/>\nThat video then will show on the detail page in the content section of the listing.<br \/>\nThis article explains how you can move the video from the content section to the sidebar.<\/p>\n","protected":false},"author":1676,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[],"amp_validity":null,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/posts\/22651"}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/users\/1676"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/comments?post=22651"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/posts\/22651\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/media?parent=22651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/categories?post=22651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs\/wp-json\/wp\/v2\/tags?post=22651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}