I've inherited some SASS code used for theming from someone and it looks like it is only compiling into rules that target children of the element that has the themed class.
$themes:(
default:(
background:#CCCCCC
)
);
#mixin themify($themes: $themes) {
#each $theme, $map in $themes {
.theme-#{$theme} & {
$theme-map: () !global;
#each $key, $submap in $map {
$value: map-get(map-get($themes, $theme), '#{$key}');
$theme-map: map-merge($theme-map, ($key: $value)) !global;
}
#content;
$theme-map: null !global;
}
}
}
#function themed($key) {
#return map-get($theme-map, $key);
}
Gives a compiled css rule as
.theme-default body {
background-color: #CCCCCC;
}
The code seems fine but the highest element that can have the themed class is the body but then how can the body be given a themed property? I tried to add an additional mixin that will not use the children (just removing the & to invert the element relation)
#mixin themifyDirect($themes: $themes) {
#each $theme, $map in $themes {
.theme-#{$theme} {
$theme-map: () !global;
#each $key, $submap in $map {
$value: map-get(map-get($themes, $theme), '#{$key}');
$theme-map: map-merge($theme-map, ($key: $value)) !global;
}
#content;
$theme-map: null !global;
}
}
}
But this compiles into a css rule
body .theme-default {
background-color: #26282F; }
This is close but not enough because the rule I need is
body.theme-default {
background-color: #CCCCCC;
}
To target body which has the class
#mixin themifyDirect($themes: $themes) {
#each $theme, $map in $themes {
&.theme-#{$theme} {
$theme-map: () !global;
#each $key, $submap in $map {
$value: map-get(map-get($themes, $theme), '#{$key}');
$theme-map: map-merge($theme-map, ($key: $value)) !global;
}
#content;
$theme-map: null !global;
}
}
}
outputs
body.theme-default {
background-color: #CCCCCC;
}
You we're really close - note the leading '&' on line 3 which removes the space.
I'm trying to use Sass / SCSS to unify the #content directive to the parent class. I am attempting to use a conditional statement within the mixin to allow for both use cases:
$themes: (
Light: (
page_background: #ffffff,
),
Dark: (
page_background: #181818,
)
);
#function get_color($key) {
#return map-get($theme-map, $key);
}
#mixin theme($makeAncestor: true) {
#each $theme, $map in $themes {
$theme-map: $map !global;
#if $makeAncestor {
.#{$theme} & {
#content;
}
} #else {
.#{$theme} & {
#content;
}
}
}
$theme-map: null !global;
}
.fixed {
#include theme() {
background: get_color(page_background);
}
}
Here is the output:
.Light .fixed {
background: #ffffff;
}
Desired output:
.Light.fixed {
background: #ffffff;
}
You can use #at-root in your mixin and interpolate the parent selector:
#mixin theme($makeAncestor: true) {
#at-root {
#each $theme, $map in $themes {
$theme-map: $map !global;
#if $makeAncestor {
.#{$theme}#{&} {
#content;
}
} #else {
.#{$theme}#{&} {
#content;
}
}
}
$theme-map: null !global;
}
}
Good morning, I've build a custom vue carousel and implemented it into my progressive web app. Works fine on Chrome Android, whereas on iOS Safari - id doesn't. I received feedback that the carousel only allows to slide the first page and on the second - it doesn't react.
The problem is, I don't own Mac or Iphone and for now I can't test it myself. Could someone help me out and test the carousel on aforementioned devices? Here is the fiddle.
https://jsfiddle.net/LSliwa/97cpgq3z/
HTML:
<div id="app">
<Carousel>
<div v-for="(todo, index) in todos" :key="index">
<div class="app__element">
{{ todo.text }}
</div>
</div>
</Carousel>
</div>
CSS:
#app {
padding-top: 1rem;
}
.app__element {
text-align: center;
border: 1px solid red;
padding: 1rem;
margin: 0 1rem;
}
/* carousel styles */
.carousel {
overflow-x: hidden;
overflow-y: visible;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.carousel-navdots {
display: flex;
justify-content: center;
margin-bottom: 2rem;
}
.carousel-navdot {
height: 10px;
width: 10px;
border-radius: 50%;
background-color: gray;
margin: 0 5px;
transition: all 0.5s;
cursor: pointer;
}
.active {
background-color: #05AA19;
}
.carousel-wrapper {
display: flex;
align-items: stretch;
cursor: grab;
}
.carousel-wrapper:active {
cursor: grabbing;
}
.carousel-wrapper>div,
.carousel-wrapper>p,
.carousel-wrapper>span,
.carousel-wrapper>ul {
width: 100%;
flex-shrink: 0;
position: relative;
}
.scrolling {
transition: transform 0.5s;
}
.inactive {
flex-direction: column;
}
#media (min-width: 1024px) {
.inactive {
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
}
}
JS:
Vue.component('Carousel', {
template: '<div class="carousel"><div class="carousel-navdots" v-if="isActive" v-show="pagination"><div class="carousel-navdot" :class="{ \'active\': n == currentPage + 1 }" v-for="n in numberOfPages" v-show="numberOfPages > 1" :key="n" ref="navdot" #click="scrollWithNavdots(n)"></div></div><div class="carousel-wrapper a-stretch" :class="{ \'inactive\': !isActive }" :style="{ transform: `translateX(${translate}px)` }" ref="wrapper" v-on="isActive && active ? { touchstart: onTouchStart, touchmove: onTouchMove, touchend: onTouchEnd, mousedown: onTouchStart, mousemove: onTouchMove, mouseup: onTouchEnd } : {}"><slot></slot></div></div>',
props: {
active: {
type: Boolean,
default: () => true
},
activeOnViewport: {
type: Array,
default: () => [[1, true]]
},
columns: {
type: Array,
default: () => [[1, 1]]
},
pagination: {
type: Boolean,
default: () => true
},
sensitivity: {
type: Number,
default: () => 40
},
startFromPage: {
type: Number,
default: () => 0
},
autoplay: {
type: Boolean,
default: () => false
},
autoplaySpeed: {
type: Number,
default: () => 5
},
// usuń custom length jeżeli rerendering z :key zadziała
customLength: {
type: Number
}
},
data() {
return {
currentPage: this.startFromPage,
numberOfColumns: 1,
moveStart: null,
move: null,
currentTranslate: 0,
length: this.customLength == null ? this.$slots.default.length : this.customLength,
viewportColumnsMatched: null,
isActive: null,
mousedown: false,
elementWidth: 0,
autoplayInterval: null,
animateTimeout: null,
test: {
touchmove: false,
touchstart: false,
}
}
},
computed: {
maxScrollLeft() {
return this.currentPage == 0 ? true : false;
},
maxScrollRight() {
return this.currentPage + 1 == this.numberOfPages ? true : false;
},
numberOfPages() {
return Math.ceil(this.length / this.numberOfColumns);
},
sortedColumns() {
return this.columns.sort((a, b) => {
return a[0] - b[0];
});
},
sortedActive() {
return this.activeOnViewport.sort((a, b) => {
return a[0] - b[0];
})
},
translate() {
return -this.elementWidth * this.currentPage
}
},
watch: {
currentPage() {
this.animateCarousel();
this.$emit('change-page', this.currentPage);
},
startFromPage() {
this.currentPage = this.startFromPage;
},
// usuń watch customLength jeżeli rerendering z :key zadziała
customLength() {
this.length = this.customLength;
if (this.currentPage > this.length - 1) {
this.currentPage = this.length - 1;
}
}
},
methods: {
animateCarousel() {
this.$refs.wrapper.classList.add('scrolling');
this.animateTimeout = setTimeout(() => {
this.$refs.wrapper.classList.remove('scrolling');
}, 500);
},
scrollWithNavdots(index) {
this.currentPage = index - 1;
this.currentTranslate = parseFloat(this.$refs.wrapper.style.transform.slice(11, -3));
},
onTouchStart() {
clearInterval(this.autoplayInterval);
if (event.type == 'touchstart') {
this.moveStart = event.touches[0].screenX
} else {
this.moveStart = event.screenX;
this.mousedown = true;
}
},
onTouchMove() {
let translate;
if (event.type == 'touchmove') {
this.move = event.touches[0].screenX - this.moveStart;
} else if (event.type == 'mousemove' && this.mousedown == true) {
this.move = event.screenX - this.moveStart
}
if (this.move < 0 && this.maxScrollRight || this.move > 0 && this.maxScrollLeft) {
translate = this.translate + this.move*0.2;
} else {
translate = this.translate + this.move*0.5;
}
this.$refs.wrapper.style.transform = `translateX(${translate}px)`;
},
onTouchEnd() {
this.test.touchstart = false;
this.test.touchmove = false;
if (Math.abs(this.move) > this.sensitivity) {
if (this.move > 0 && !this.maxScrollLeft) {
this.currentPage--
} else if (this.move < 0 && !this.maxScrollRight) {
this.currentPage++
} else {
this.animateCarousel();
}
} else if (Math.abs(this.move) < this.sensitivity && Math.abs(this.move) > 1) {
this.animateCarousel();
}
this.$refs.wrapper.style.transform = `translateX(${this.translate}px)`;
this.mousedown = false;
this.moveStart = null;
this.move = null;
},
setColumns() {
this.viewportColumnsMatched = false;
this.sortedColumns.forEach(cur => {
if (window.matchMedia(`(min-width: ${cur[0]}px)`).matches) {
this.viewportColumnsMatched = true;
this.numberOfColumns = cur[1];
this.$refs.wrapper.childNodes.forEach(cur => {
cur.style.width = `${100/this.numberOfColumns}%`;
});
}
});
if (!this.viewportColumnsMatched) {
this.numberOfColumns = 1;
this.$refs.wrapper.childNodes.forEach(cur => {
cur.style.width = '100%';
});
}
setTimeout(() => {
this.elementWidth = this.$slots.default[0].elm.offsetWidth;
});
},
setActive() {
this.sortedActive.forEach(cur => {
if (window.matchMedia(`(min-width: ${cur[0]}px)`).matches) {
this.isActive = cur[1];
}
});
},
runCarousel() {
if (this.autoplay) {
this.autoplayInterval = setInterval(() => {
this.currentPage++
if (this.currentPage == this.numberOfPages) this.currentPage = 0;
}, this.autoplaySpeed * 1000);
}
},
},
mounted() {
this.setColumns();
this.setActive();
this.runCarousel();
window.addEventListener('resize', () => {
this.setColumns();
this.setActive();
});
},
destroyed() {
clearInterval(this.autoplayInterval);
clearTimeout(this.animateTimeout);
}
});
new Vue({
el: "#app",
data: {
todos: [
{ text: "Learn JavaScript", done: false },
{ text: "Learn Vue", done: false },
{ text: "Play around in JSFiddle", done: true },
{ text: "Build something awesome", done: true }
]
},
})
Thank you in advance for your help, good people.
I am trying to retrieve the Post Title from a WordPress object.
Here is a var_dump resulting from the WP_Query:
object(WP_Query)#4305 (49) { ["query"]=> array(2) { ["post_type"]=>
string(5) "cases" ["posts_per_page"]=> int(-1) } ["query_vars"]=>
array(64) { ["post_type"]=> string(5) "cases" ["posts_per_page"]=>
int(-1) ["error"]=> string(0) "" ["m"]=> string(0) "" ["p"]=> int(0)
["post_parent"]=> string(0) "" ["subpost"]=> string(0) ""
["subpost_id"]=> string(0) "" ["attachment"]=> string(0) ""
["attachment_id"]=> int(0) ["name"]=> string(0) "" ["static"]=>
string(0) "" ["pagename"]=> string(0) "" ["page_id"]=> int(0)
["second"]=> string(0) "" ["minute"]=> string(0) "" ["hour"]=>
string(0) "" ["day"]=> int(0) ["monthnum"]=> int(0) ["year"]=> int(0)
["w"]=> int(0) ["category_name"]=> string(0) "" ["tag"]=> string(0) ""
["cat"]=> string(0) "" ["tag_id"]=> string(0) "" ["author"]=>
string(0) "" ["author_name"]=> string(0) "" ["feed"]=> string(0) ""
["tb"]=> string(0) "" ["paged"]=> int(0) ["meta_key"]=> string(0) ""
["meta_value"]=> string(0) "" ["preview"]=> string(0) "" ["s"]=>
string(0) "" ["sentence"]=> string(0) "" ["title"]=> string(0) ""
["fields"]=> string(0) "" ["menu_order"]=> string(0) "" ["embed"]=>
string(0) "" ["category__in"]=> array(0) { } ["category__not_in"]=>
array(0) { } ["category__and"]=> array(0) { } ["post__in"]=> array(0)
{ } ["post__not_in"]=> array(0) { } ["post_name__in"]=> array(0) { }
["tag__in"]=> array(0) { } ["tag__not_in"]=> array(0) { }
["tag__and"]=> array(0) { } ["tag_slug__in"]=> array(0) { }
["tag_slug__and"]=> array(0) { } ["post_parent__in"]=> array(0) { }
["post_parent__not_in"]=> array(0) { } ["author__in"]=> array(0) { }
["author__not_in"]=> array(0) { } ["ignore_sticky_posts"]=>
bool(false) ["suppress_filters"]=> bool(false) ["cache_results"]=>
bool(true) ["update_post_term_cache"]=> bool(true)
["lazy_load_term_meta"]=> bool(true) ["update_post_meta_cache"]=>
bool(true) ["nopaging"]=> bool(true) ["comments_per_page"]=> string(2)
"50" ["no_found_rows"]=> bool(false) ["order"]=> string(4) "DESC" }
["tax_query"]=> object(WP_Tax_Query)#4307 (6) { ["queries"]=> array(0)
{ } ["relation"]=> string(3) "AND" ["table_aliases":protected]=>
array(0) { } ["queried_terms"]=> array(0) { } ["primary_table"]=>
string(8) "wp_posts" ["primary_id_column"]=> string(2) "ID" }
["meta_query"]=> object(WP_Meta_Query)#4303 (9) { ["queries"]=>
array(0) { } ["relation"]=> NULL ["meta_table"]=> NULL
["meta_id_column"]=> NULL ["primary_table"]=> NULL
["primary_id_column"]=> NULL ["table_aliases":protected]=> array(0) {
} ["clauses":protected]=> array(0) { } ["has_or_relation":protected]=>
bool(false) } ["date_query"]=> bool(false) ["request"]=> string(259)
"SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type =
'cases' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status
= 'acf-disabled' OR wp_posts.post_author = 44 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC " ["posts"]=> array(42) { [0]=> object(WP_Post)#4270 (24) { ["ID"]=> int(19269)
["post_author"]=> string(1) "2" ["post_date"]=> string(19) "2018-10-02
10:46:05" ["post_date_gmt"]=> string(19) "2018-10-02 08:46:05"
["post_content"]=> string(0) "" ["post_title"]=> string(17) "Terberg -
ANNAbel" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7)
"publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=>
string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=>
string(7) "annabel" ["to_ping"]=> string(0) "" ["pinged"]=> string(0)
"" ["post_modified"]=> string(19) "2018-11-15 12:37:10"
["post_modified_gmt"]=> string(19) "2018-11-15 11:37:10"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19269"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [1]=> object(WP_Post)#4269 (24) {
["ID"]=> int(19161) ["post_author"]=> string(1) "2" ["post_date"]=>
string(19) "2018-09-28 15:46:05" ["post_date_gmt"]=> string(19)
"2018-09-28 13:46:05" ["post_content"]=> string(0) "" ["post_title"]=>
string(19) "De Voordelige Groep" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(19) "de-voordelige-groep"
["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:28:00"
["post_modified_gmt"]=> string(19) "2018-11-15 11:28:00"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19161"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [2]=> object(WP_Post)#4268 (24) {
["ID"]=> int(19163) ["post_author"]=> string(1) "2" ["post_date"]=>
string(19) "2018-09-28 15:42:12" ["post_date_gmt"]=> string(19)
"2018-09-28 13:42:12" ["post_content"]=> string(0) "" ["post_title"]=>
string(16) "Global Factories" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(16) "global-factories"
["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:41:57"
["post_modified_gmt"]=> string(19) "2018-11-15 11:41:57"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19163"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [3]=> object(WP_Post)#4267 (24) {
["ID"]=> int(19167) ["post_author"]=> string(1) "2" ["post_date"]=>
string(19) "2018-09-21 14:58:50" ["post_date_gmt"]=> string(19)
"2018-09-21 12:58:50" ["post_content"]=> string(0) "" ["post_title"]=>
string(24) "Warmteservice Groep B.V." ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(13) "warmteservice" ["to_ping"]=>
string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19)
"2018-11-15 12:00:56" ["post_modified_gmt"]=> string(19) "2018-11-15
11:00:56" ["post_content_filtered"]=> string(0) "" ["post_parent"]=>
int(0) ["guid"]=> string(48)
"https://www.zeo.nl/?post_type=cases&p=19167" ["menu_order"]=> int(0)
["post_type"]=> string(5) "cases" ["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [4]=>
object(WP_Post)#4266 (24) { ["ID"]=> int(19157) ["post_author"]=>
string(1) "2" ["post_date"]=> string(19) "2018-09-21 11:26:12"
["post_date_gmt"]=> string(19) "2018-09-21 09:26:12"
["post_content"]=> string(0) "" ["post_title"]=> string(9) "Blauwtulp"
["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish"
["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6)
"closed" ["post_password"]=> string(0) "" ["post_name"]=> string(11)
"blauwtulp-2" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:46:48"
["post_modified_gmt"]=> string(19) "2018-11-15 11:46:48"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19157"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [5]=> object(WP_Post)#4265 (24) {
["ID"]=> int(19154) ["post_author"]=> string(1) "2" ["post_date"]=>
string(19) "2018-09-21 11:15:52" ["post_date_gmt"]=> string(19)
"2018-09-21 09:15:52" ["post_content"]=> string(0) "" ["post_title"]=>
string(22) "AO Smith International" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(8) "ao-smith" ["to_ping"]=>
string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19)
"2018-11-15 12:39:59" ["post_modified_gmt"]=> string(19) "2018-11-15
11:39:59" ["post_content_filtered"]=> string(0) "" ["post_parent"]=>
int(0) ["guid"]=> string(48)
"https://www.zeo.nl/?post_type=cases&p=19154" ["menu_order"]=> int(0)
["post_type"]=> string(5) "cases" ["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [6]=>
object(WP_Post)#4264 (24) { ["ID"]=> int(19103) ["post_author"]=>
string(1) "3" ["post_date"]=> string(19) "2018-09-12 12:13:53"
["post_date_gmt"]=> string(19) "2018-09-12 10:13:53"
["post_content"]=> string(0) "" ["post_title"]=> string(10)
"FixFast.de" ["post_excerpt"]=> string(0) "" ["post_status"]=>
string(7) "publish" ["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) ""
["post_name"]=> string(10) "fixfast-de" ["to_ping"]=> string(0) ""
["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2018-11-15
12:23:55" ["post_modified_gmt"]=> string(19) "2018-11-15 11:23:55"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19103"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [7]=> object(WP_Post)#4263 (24) {
["ID"]=> int(19072) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-09-05 13:05:27" ["post_date_gmt"]=> string(19)
"2018-09-05 11:05:27" ["post_content"]=> string(0) "" ["post_title"]=>
string(8) "Shopware" ["post_excerpt"]=> string(0) "" ["post_status"]=>
string(7) "publish" ["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) ""
["post_name"]=> string(8) "shopware" ["to_ping"]=> string(0) ""
["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2018-09-05
13:30:52" ["post_modified_gmt"]=> string(19) "2018-09-05 11:30:52"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19072"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [8]=> object(WP_Post)#4262 (24) {
["ID"]=> int(18910) ["post_author"]=> string(1) "2" ["post_date"]=>
string(19) "2018-07-12 14:16:15" ["post_date_gmt"]=> string(19)
"2018-07-12 12:16:15" ["post_content"]=> string(0) "" ["post_title"]=>
string(11) "Burger King" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(13) "burger-king-2" ["to_ping"]=>
string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19)
"2018-11-15 11:59:50" ["post_modified_gmt"]=> string(19) "2018-11-15
10:59:50" ["post_content_filtered"]=> string(0) "" ["post_parent"]=>
int(0) ["guid"]=> string(48)
"https://www.zeo.nl/?post_type=cases&p=18910" ["menu_order"]=> int(0)
["post_type"]=> string(5) "cases" ["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [9]=>
object(WP_Post)#4261 (24) { ["ID"]=> int(18907) ["post_author"]=>
string(1) "2" ["post_date"]=> string(19) "2018-07-12 13:50:43"
["post_date_gmt"]=> string(19) "2018-07-12 11:50:43"
["post_content"]=> string(0) "" ["post_title"]=> string(14) "Ideal
Standard" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7)
"publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=>
string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=>
string(14) "ideal-standard" ["to_ping"]=> string(0) "" ["pinged"]=>
string(0) "" ["post_modified"]=> string(19) "2018-11-15 12:06:02"
["post_modified_gmt"]=> string(19) "2018-11-15 11:06:02"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18907"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [10]=> object(WP_Post)#4260 (24) {
["ID"]=> int(18760) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-07-11 12:29:18" ["post_date_gmt"]=> string(19)
"2018-07-11 10:29:18" ["post_content"]=> string(0) "" ["post_title"]=>
string(18) "Thomas Stofzuigers" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(20) "thomas-stofzuigers-2"
["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:44:26"
["post_modified_gmt"]=> string(19) "2018-11-15 11:44:26"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18760"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [11]=> object(WP_Post)#4259 (24) {
["ID"]=> int(18858) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-07-11 12:10:23" ["post_date_gmt"]=> string(19)
"2018-07-11 10:10:23" ["post_content"]=> string(0) "" ["post_title"]=>
string(22) "Waaijenberg Mobiliteit" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(22) "waaijenberg-mobiliteit"
["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:24:50"
["post_modified_gmt"]=> string(19) "2018-11-15 11:24:50"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18858"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [12]=> object(WP_Post)#4258 (24) {
["ID"]=> int(18852) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-07-11 10:04:06" ["post_date_gmt"]=> string(19)
"2018-07-11 08:04:06" ["post_content"]=> string(0) "" ["post_title"]=>
string(20) "Buiskoppelingshop.nl" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(22) "buiskoppelingshop-nl-2"
["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:26:55"
["post_modified_gmt"]=> string(19) "2018-11-15 11:26:55"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18852"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [13]=> object(WP_Post)#4257 (24) {
["ID"]=> int(18655) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-05-24 13:10:32" ["post_date_gmt"]=> string(19)
"2018-05-24 11:10:32" ["post_content"]=> string(0) "" ["post_title"]=>
string(8) "SprayPay" ["post_excerpt"]=> string(0) "" ["post_status"]=>
string(7) "publish" ["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) ""
["post_name"]=> string(8) "spraypay" ["to_ping"]=> string(0) ""
["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2018-05-24
13:13:14" ["post_modified_gmt"]=> string(19) "2018-05-24 11:13:14"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18655"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [14]=> object(WP_Post)#4256 (24) {
["ID"]=> int(18653) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-05-24 12:17:25" ["post_date_gmt"]=> string(19)
"2018-05-24 10:17:25" ["post_content"]=> string(0) "" ["post_title"]=>
string(5) "Sooqr" ["post_excerpt"]=> string(0) "" ["post_status"]=>
string(7) "publish" ["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) ""
["post_name"]=> string(5) "sooqr" ["to_ping"]=> string(0) ""
["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2018-05-24
12:17:25" ["post_modified_gmt"]=> string(19) "2018-05-24 10:17:25"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18653"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [15]=> object(WP_Post)#4255 (24) {
["ID"]=> int(18650) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-05-24 11:37:51" ["post_date_gmt"]=> string(19)
"2018-05-24 09:37:51" ["post_content"]=> string(0) "" ["post_title"]=>
string(6) "Pay.nl" ["post_excerpt"]=> string(0) "" ["post_status"]=>
string(7) "publish" ["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) ""
["post_name"]=> string(6) "pay-nl" ["to_ping"]=> string(0) ""
["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2018-05-24
11:43:57" ["post_modified_gmt"]=> string(19) "2018-05-24 09:43:57"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18650"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [16]=> object(WP_Post)#4254 (24) {
["ID"]=> int(18645) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-05-23 16:46:32" ["post_date_gmt"]=> string(19)
"2018-05-23 14:46:32" ["post_content"]=> string(0) "" ["post_title"]=>
string(11) "Hellodialog" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(11) "hellodialog" ["to_ping"]=>
string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19)
"2018-05-30 15:26:13" ["post_modified_gmt"]=> string(19) "2018-05-30
13:26:13" ["post_content_filtered"]=> string(0) "" ["post_parent"]=>
int(0) ["guid"]=> string(48)
"https://www.zeo.nl/?post_type=cases&p=18645" ["menu_order"]=> int(0)
["post_type"]=> string(5) "cases" ["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" }
[17]=> object(WP_Post)#4253 (24) { ["ID"]=> int(18643)
["post_author"]=> string(1) "3" ["post_date"]=> string(19) "2018-05-23
16:32:09" ["post_date_gmt"]=> string(19) "2018-05-23 14:32:09"
["post_content"]=> string(0) "" ["post_title"]=> string(16) "Feedback
Company" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7)
"publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=>
string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=>
string(16) "feedback-company" ["to_ping"]=> string(0) "" ["pinged"]=>
string(0) "" ["post_modified"]=> string(19) "2018-05-23 16:34:46"
["post_modified_gmt"]=> string(19) "2018-05-23 14:34:46"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18643"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
I am trying to get the post_title. This is what I have so far:
<?php
$args = array(
'post_type' => 'cases',
'posts_per_page' => -1,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ):
while ( $the_query->have_posts() ): $the_query->the_post();
$case_title = get_field('post_title');
echo $case_title;
var_dump($the_query);
?>
<?php endwhile; wp_reset_postdata(); endif;?>
But it is not retrieving the title.
What should I be doing to retrieve the title?
To echo the Title you can do this <?php the_title(); ?> and to put the title in a var you can do this $title = get_the_title();
for more information: https://developer.wordpress.org/reference/functions/get_the_title/
<?php
$args = array(
'post_type' => 'cases',
'posts_per_page' => -1,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ):
while ( $the_query->have_posts() ): $the_query->the_post();
$case_title = get_the_title();
echo $case_title;
// or
echo the_title();
var_dump($the_query);
?>
<?php endwhile; wp_reset_postdata(); endif;?>
I'm trying to remove a "Tags" submenu from my Portfolio menu, this is what I'm using:
add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
if(!current_user_can('create_users')) {
remove_submenu_page( 'edit.php', 'tags.php' );
remove_submenu_page( 'edit.php?post_type=portfolio', 'edit-tags.php?taxonomy=post_tag&post_type=portfolio' );
}
}
But it simply won't go. Here's the output of a var_dump($submenu); function:
Stackoverflow requires more text to the post ¬¬ so text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
array(12) {
["index.php"]=>
array(1) {
[0]=>
array(3) {
[0]=>
string(7) "Início"
[1]=>
string(4) "read"
[2]=>
string(9) "index.php"
}
}
["edit.php"]=>
array(4) {
[5]=>
array(3) {
[0]=>
string(14) "Todos os Posts"
[1]=>
string(10) "edit_posts"
[2]=>
string(8) "edit.php"
}
[10]=>
array(3) {
[0]=>
string(14) "Adicionar Novo"
[1]=>
string(10) "edit_posts"
[2]=>
string(12) "post-new.php"
}
[15]=>
array(3) {
[0]=>
string(10) "Categorias"
[1]=>
string(17) "manage_categories"
[2]=>
string(31) "edit-tags.php?taxonomy=category"
}
[16]=>
array(3) {
[0]=>
string(4) "Tags"
[1]=>
string(17) "manage_categories"
[2]=>
string(31) "edit-tags.php?taxonomy=post_tag"
}
}
["upload.php"]=>
array(1) {
[5]=>
array(3) {
[0]=>
string(10) "Biblioteca"
[1]=>
string(12) "upload_files"
[2]=>
string(10) "upload.php"
}
}
["link-manager.php"]=>
array(3) {
[5]=>
array(3) {
[0]=>
string(14) "Todos os Links"
[1]=>
string(12) "manage_links"
[2]=>
string(16) "link-manager.php"
}
[10]=>
array(3) {
[0]=>
string(14) "Adicionar novo"
[1]=>
string(12) "manage_links"
[2]=>
string(12) "link-add.php"
}
[15]=>
array(3) {
[0]=>
string(19) "Categorias de Links"
[1]=>
string(17) "manage_categories"
[2]=>
string(36) "edit-tags.php?taxonomy=link_category"
}
}
["edit.php?post_type=page"]=>
array(2) {
[5]=>
array(3) {
[0]=>
string(17) "Todas as Páginas"
[1]=>
string(10) "edit_pages"
[2]=>
string(23) "edit.php?post_type=page"
}
[10]=>
array(3) {
[0]=>
string(14) "Adicionar Nova"
[1]=>
string(10) "edit_pages"
[2]=>
string(27) "post-new.php?post_type=page"
}
}
["edit-comments.php"]=>
array(1) {
[0]=>
array(3) {
[0]=>
string(21) "Todos os Comentários"
[1]=>
string(10) "edit_posts"
[2]=>
string(17) "edit-comments.php"
}
}
["edit.php?post_type=portfolio"]=>
array(4) {
[5]=>
array(3) {
[0]=>
string(9) "Portfolio"
[1]=>
string(10) "edit_posts"
[2]=>
string(28) "edit.php?post_type=portfolio"
}
[10]=>
array(3) {
[0]=>
string(14) "Adicionar Novo"
[1]=>
string(10) "edit_posts"
[2]=>
string(32) "post-new.php?post_type=portfolio"
}
[15]=>
array(3) {
[0]=>
string(4) "Tags"
[1]=>
string(17) "manage_categories"
[2]=>
string(55) "edit-tags.php?taxonomy=post_tag&post_type=portfolio"
}
[16]=>
array(3) {
[0]=>
string(23) "Categorias de Portfolio"
[1]=>
string(17) "manage_categories"
[2]=>
string(65) "edit-tags.php?taxonomy=portfolio_category&post_type=portfolio"
}
}
["edit.php?post_type=slideshow"]=>
array(2) {
[5]=>
array(3) {
[0]=>
string(7) "Banners"
[1]=>
string(10) "edit_posts"
[2]=>
string(28) "edit.php?post_type=slideshow"
}
[10]=>
array(3) {
[0]=>
string(14) "Adicionar Novo"
[1]=>
string(10) "edit_posts"
[2]=>
string(32) "post-new.php?post_type=slideshow"
}
}
["themes.php"]=>
array(1) {
[10]=>
array(3) {
[0]=>
string(5) "Menus"
[1]=>
string(18) "edit_theme_options"
[2]=>
string(13) "nav-menus.php"
}
}
["profile.php"]=>
array(1) {
[5]=>
array(3) {
[0]=>
string(10) "Seu perfil"
[1]=>
string(4) "read"
[2]=>
string(11) "profile.php"
}
}
["tools.php"]=>
array(1) {
[5]=>
array(3) {
[0]=>
string(12) "Disponíveis"
[1]=>
string(10) "edit_posts"
[2]=>
string(9) "tools.php"
}
}
["options-general.php"]=>
array(1) {
[0]=>
array(4) {
[0]=>
string(16) "Support settings"
[1]=>
int(1)
[2]=>
string(16) "support_settings"
[3]=>
string(16) "Support settings"
}
}
}
The example put forth on the Codex page for remove_submenu_page sets the optional 3rd parameter on add_action to 999 for the "priority".
I'm not sure if adding this to your code will make it work, but its worth a try.
<?php
add_action( 'admin_menu', 'adjust_the_wp_menu', 999 );
function adjust_the_wp_menu() {
$page = remove_submenu_page( 'themes.php', 'widgets.php' );
}
?>