You’re very welcome.
The docs for getting the label of a field as well as the value are here: http://www.advancedcustomfields.com/resources/get_field_object/
This means that for the lines like this:
$data_1 = get_field('2g_network');
That returns only the value. So you would now have
$data_1 = get_field_object('2g_network');
Which returns an object with various keys, including “label” and “value”.
Once you have that object, you could change lines like this:
$to_echo .= $data_1;
to lines that use specific parts of that object.
$to_echo .= $data_1["label"] . ': ' . $data_1["value"];
Have fun!
Yes, just checked your file and the problem is in the context — you forgot to wrap the new code in a <?php> tag. Hence it’s being treated as HTML. Your whole file should look like this:
<?php
/**
* The single post loop for post template 1
**/
if (have_posts()) {
the_post();
$td_mod_single = new td_module_1($post);
//show the breadcrumb
if (get_post_type($post) == 'post') {
echo td_page_generator::get_single_breadcrumbs($td_mod_single->title);
} else {
echo td_page_generator::get_page_breadcrumbs($td_mod_single->title);
}
?>
<article id="post-<?php echo $td_mod_single->post->ID;?>" class="<?php echo join(' ', get_post_class());?>" <?php echo $td_mod_single->get_item_scope();?>>
<header>
<?php echo $td_mod_single->get_title();?>
<div class="meta-info">
<?php echo $td_mod_single->get_category();?>
<?php //echo $td_mod_single->get_author();?>
<?php echo $td_mod_single->get_date(false);?>
<?php echo $td_mod_single->get_commentsAndViews();?>
</div>
</header>
<?php if (!empty($td_mod_single->td_post_theme_settings['td_subtitle'])) { ?>
<p class="td-sub-title"><?php echo $td_mod_single->td_post_theme_settings['td_subtitle'];?></p>
<?php } ?>
<?php
// override the default featured image by the templates (single.php and home.php/index.php - blog loop)
if (!empty(td_global::$load_featured_img_from_template)) {
echo $td_mod_single->get_image(td_global::$load_featured_img_from_template);
} else {
echo $td_mod_single->get_image('art-big-1col');
}
?>
<div class="td-post-text-content">
<?php echo $td_mod_single->get_content();?>
<?php
// Set up your row, column, and tabs element
$to_echo = '[vc_row][vc_column width="1/1"][vc_tabs]';
// Simplest possible example of getting ACF data, sub in yours
$data_1 = get_field('2g_network');
$data_2 = get_field('3g_network');
// Repeat these lines for each tab, making sure each tab has a unique id
$to_echo .= '[vc_tab title="The first tab" tab_id="tab_1"]';
$to_echo .= $data_1;
$to_echo .= '[/vc_tab]';
$to_echo .= '[vc_tab title="The second tab" tab_id="tab_2"]';
$to_echo .= $data_2;
$to_echo .= '[/vc_tab]';
// (You could wrap each block in an if to skip a tab if the data is empty)
// When you have all your tabs, close the elements
$to_echo .= '[/vc_tabs][/vc_column][/vc_row]';
// We have to filter the whole string to make WP interpret the shortcodes
$to_echo = wpb_js_remove_wpautop($to_echo);
// Do whatever
echo $to_echo;
?>
</div>
<div class="clearfix"></div>
<footer>
<?php echo $td_mod_single->get_post_pagination();?>
<?php echo $td_mod_single->get_review();?>
<?php echo $td_mod_single->get_source_and_via();?>
<?php echo $td_mod_single->get_social_sharing();?>
<?php echo $td_mod_single->get_social_like_tweet();?>
<?php echo $td_mod_single->get_next_prev_posts();?>
<?php echo $td_mod_single->get_author_box();?>
<?php echo $td_mod_single->get_item_scope_meta();?>
</footer>
</article> <!-- /.post -->
<?php echo $td_mod_single->related_posts();?>
<?php
} else {
//no posts
echo td_page_generator::no_posts();
}?>
P.S. Rather than use mb_strtoupper, why not style text-transform on the block titles so it’s easier to just change via CSS? (This is half a suggestion and half me actually asking because I don’t know which way is better.)
I don’t really know how to fix the left problem; I would probably just drop the CSS for the horizontal whitespace since it’s likely to break the grid. Or at least limit it by screen size:
@media (min-width: 1019px) {
.span1, .span3, .span4, .span6, .span8, .span9, .span11, .span12 { margin-left: 20px !important; }
}
Space between menu and content, in four directions so you can adjust more easily:
.td-grid-wrap {
padding: 0px 0px 0px 0px;
}
It’s a little bit of custom work, so if you aren’t comfortable coding you’ll have to find someone. I did this recently and my own steps were:
1. Replaced searchform.php with my own (so widgets would be replaced with mine too; not necessary, you could just use the theme default)
2. Edited the div for the search out of the menu in menu-header.php and menu-header-center.php (one or the other, I forget which), and instead had a div that uses the WP function get_search_form()
3. Styled my new div using CSS to sit at the right of the menu, use my own icon, etc.
Theme Panel -> Categories -> The categories you want to remove sliders from -> Turn off “show slider” for each one
Great! Yeah, your homepage will be using the modules. They can be found in your WordPress directory like this: /wp-content/themes/Newspaper/includes/modules. The specific line is:
<?php //echo $this->get_author();?>
Which will become:
<?php echo $this->get_author();?>
I seem to remember having little luck with that. I think the way I ended up doing it was copying, renaming, and editing the functions in my child theme functions.php, then removing the action or filter of the parent function and adding the action or filter of my own.
It definitely does work; a large number of us use it 🙂
The most common reason I’ve heard for the result you’re describing is that you have minifying CSS and/or JS turned on in W3 Total Cache. Not all themes play well with minifying.
@mehedi agreed that it’s not ideal, but I thought since on mobile and tablets the footer gets vertically stacked, is there much whitespace to worry about from the empty columns? If so you could maybe use nth-child to hide those columns altogether:
@media (max-width: 1018px) {
.td-footer-wrap .wpb_row > div:nth-child(1), .td-footer-wrap .wpb_row > div:nth-child(2) {
display: none !important;
}
}
Does that work for you or still too much whitespace?
This has been asked a couple of times recently, so you’re not alone. (I would love something like that too.) TagDiv has said that they’ll add it to their feature requests list and consider it for a future update.
I used this plugin once and it worked (and removes, not just hides!) but it’s on a page-by-page basis: https://wordpress.org/plugins/toggle-the-title/
Yup, I noticed this too when adding a Twitter account link.
Glad you solved it. 🙂
Log in to your site. Visit your site’s homepage. There should now be a black bar across the top (the admin menu). One of the buttons says “Edit Page”. http://www.screencast.com/t/NuUpOguC
(It’s also possible to get there from Dashboard -> Pages -> All pages, but I don’t know the exact name of your homepage.)
The edits are good but they only apply to one of many possible templates your posts can have. Do the exact same code edit (uncommenting the byline) in each of the following files:
loop-single.php, loop-single-1.php, single_template_2.php, single_template_3.php, single_template_4.php, single_template_5.php
And if you want, a similar edit for each of these files in includes/modules (the modules display posts in blocks and archive pages mainly):
td_module_1.php, td_module_2.php, td_module_3.php, td_module_4.php, td_module_5.php, td_module_6.php, td_module_8.php, td_module_9.php, td_module_aj_search.php, and td_module_search.php (if it isn’t already uncommented in that last one).
Happy editing!
(Just poking my head in to say that I would definitely love that feature too; it was one of my first questions)
The exact same result? Even if the above doesn’t parse the tabs as it should, it would at least stop echoing the comments. If it’s the exact same make sure you saved the file and cleared your browser cache / cache plugin if you use one.
So you pretty much want all the whitespace gone at once? That’s a lot of CSS; here’s my shot at it.
First, still keep this:
.td_mod_wrap .meta-info {
display: none !important;
}
Now:
.td_block_wrap {
margin-bottom: 0px;
padding-bottom: 0px;
}
.td_mod_wrap {
margin-bottom: 0px;
}
.td_mod1, .td_mod2, .td_mod3, .td_mod4, .td_mod5, .td_mod6, .td_mod7, .td_mod8, .td_mod9 {
margin-bottom: 0px!important;
}
.block-title {
margin-bottom: 0px;
padding-bottom: 0px;
}
.td_mod_wrap .thumb-wrap {
margin-bottom: 0px;
}
.wpb_row {
margin-bottom: 0px;
}
.td_mod3 {
min-height: 65px;
}
This removes all the whitespace that I could see on your homepage. As others have said, I actually think this is way too dense a style. Having some whitespace is good!… Play with the above numbers until you’re happy with it.
This last bit is the whitespace between vertical elements. It’s experiemntal and I haven’t tested it thoroughly. It’s tricky to get rid of this because it does not play well with the grid layout that the whole theme is designed around (and doesn’t change the overall site width, e.g. your main menu). I would personally avoid using it.
.span1, .span3, .span4, .span6, .span8, .span9, .span11, .span12 {
margin-left: 0px !important;
}
Again, change that number and if necessary separate the individual span classes so you can adjust their margins individually.
Note that it looks like you have a row after your video in the page editor, which is the source of the whitespace between that and the footer. You also have a text widget in the sidebar, which is the source of the whitespace above the socials widget.
There may also be whitespace elsewhere on your site that’s not on the homepage. Most of it would be caught by the above, I think…
This in the docs, as Lucian said:
Go to your homepage while logged in.
Click “Edit page” in the admin bar at the top.
If you see a blue button labelled “Backend editor”, click it.
You are now in the Visual Composer editor.
You’ll see the rows and columns that your homepage is made up of. Inside the columns are blocks.
Edit individual blocks to change their settings, including their titles.
This is also where you change which posts these blocks show!
Interesting problem! Glad you got it working as far as you did. I think Lucian will have to be the one who figures out why it doesn’t work with site background. :p
Hi Ecofame,
Quick clarifications:
1. It shouldn’t make a difference between the child and parent themes.
2. A CDN is a content delivery network, used to serve your site to people faster. Don’t worry — if you don’t know what it is, you’re probably not using one 😉
3. The caching plugin is actually what would have prevented you from seeing the changes, and then you would have had to clear its cache. You can deactivate it for now (although they’re often helpful, it’s not the problem or the solution at the moment).
Now, on to business.
Can you explain which whitespace you want to remove on your site? There are a lot of options. The CSS that Lucian and I gave you got rid of white space under each row of articles, because that’s what the first people in this thread were asking for, and I can see the difference on your site now.
But I assume there’s more that you want to remove. Maybe you can point out the whitespaces you want to remove on this screenshot of your site?
I do find the copyright one works on mobile and tablet (at least, mine does).
One way to disable the widgets, although it’s just lazily hiding it, is this:
1. Install https://wordpress.org/plugins/zigwidgetclass/
2. Give all the widgets in the footers you don’t want a class like hide_on_mobile
3. Go to Theme Panel -> Custom CSS and create a class like this:
@media (max-width: 1018px) {
.hide_on_mobile {
display: none !important;
}
}
@media (min-width: 1019px) {
.hide_on_mobile {
display: initial !important;
}
}
Note that you may have to use a different number of px to pick out the exact screen sizes you want. If I remember right, the other breaks used in the theme are 1200, 768, and 480.
Make sure you also update the Revolution Slider and Visual Composer (filename js-composer) plugins, if you haven’t already. These files are found in the plugins folder in the zip you download from Themeforest and must be updated individually from the theme.
Minifying is reducing file size by removing unnecessary data (e.g. line breaks). Caching / minifying / performance / speed plugins usually do it. The problem is that it can break up the flow of parsing the CSS file (if I understand it right).
Support has said in other threads that minifying CSS through plugins like W3 Total Cache won’t work (and I’ve seen it have the white screen effect). A CDN might also be minifying your CSS files, although I use Cloudflare and it seems fine.