New answers tagged

0

Neither is correct. page.php is a generic template that will be used for any page, automatically. You don't need to manually get the correct page content, you just need to use the correct template tags and WordPress will automatically output the correct values for the current page. <?php the_title(); ?> <?php the_content(); ?> WordPress ...


0

It's actually pretty easy... You can use a filter on theme_mod_accent_accessible_colors. You can see how the option is formatted here: https://github.com/WordPress/twentytwenty/blob/master/functions.php#L636


0

You cannot include template files via URL, which is what get_template_directory_uri() returns. You need to use the server file path, which you get get with get_theme_file_path(): $heroslider = get_theme_file_path( 'template-parts/hero-slider.php' ); echo $heroslider; include_once( $heroslider ); However, if you're including templates (rather than files ...


0

I had never used this theme until I read your question, so I decided to install it to see what you're talking about. I'm with you, not a fan of the auto colors, what a horrible idea. They say its for usability. You can read about it HERE. To answer your question, there is no built in way to change the colors, besides what you have already been doing. ...


0

What you are looking for is PHP's modulo operator and adjust markup as necessary: <?php $i = 0; $did_hr = false; $post_args = array( 'post_type' => 'Student Form', 'posts_per_page' => 6 ); $post_query = new WP_Query( $post_args ); if ( $post_query->have_posts() ) : while ( $post_query->have_posts() ) : $post_query->...


-1

If you want to show 3 posts in a list, you can follow this pattern: <?php $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DSC', 'posts_per_page' => 3 ); $post_query = new WP_Query($args); if($...


-1

Hope this code will helpful for you, i have rewrite your code with condition. I have initialize $post_count variable as 0. when displaying the post, the count get incremented. First 3 posts will display at first section and rest of the posts will display in second section. Here is the code just replace your code as below. <!-- first section starting -...


2

Use wp_get_attachment_image_src to get the image properties and URL: $logo = get_theme_mod( 'custom_logo' ); $image = wp_get_attachment_image_src( $logo , 'full' ); $image_url = $image[0]; $image_width = $image[1]; $image_height = $image[2]; Edit: Adding more information based on your comment. The URL it points to is simply made with home_url: esc_url( ...


1

There is indeed a filter, walker_nav_menu_start_el will be able to handle it for you! Take this code for example: function wpse356896_filter_primary_nav_menu_dropdown( $item_output, $item, $depth, $args ) { // Only for our primary menu location. if ( empty( $args->theme_location ) || 'primary-menu' !== $args->theme_location ) { ...


2

This is not possible, require is a PHP language construct, it's not a WordPress function, and can't be filtered or overriden via WordPress APIs These are your options: If the functionality you want to remove is implemented via actions and filters then: Unhook the things you don't want from that file Add new hooks that happen after them that attempt to ...


0

Genesis (and others like it) has always had a problem with a lack of consensus on how to cope with updates to its child themes. The simple conventional answer is that you should seldom or never update them, because it may be a very time-intensive process to avoid breaking things. StudioPress does not do auto-updates for child themes anymore, so you have to ...


0

Check Screen Options in Menu Editor window, you should have your cpt box checked.


0

I'd recommend making use of this API: https://www.countryflags.io/. You'll also need a list of countries and country codes. Download that here: https://gist.github.com/keeguon/2310008 Then, you can do something like this to register all of the countries to your custom post type's taxonomy. (you only really need to run this code once) $countries_json = ...


0

This same error is also being applied to argument issues in the add_pages_page() function. For anyone else not using add_theme_page() or add_submenu_page() functions look for your usage of add_pages_page() and correct the arguments. In my case I needed to remove the first argument which was null and give the page a title.


0

It's possible to create sites that look like that in WordPress. Probably the easiest way would be to just go in the gutenberg editor, and add a new block, go to the advanced section, and add your own CSS class per section you want to specifically target: You could use block plugins to do things like set background images, color overlays, and basic design/...


0

As stated, a theme's files is only available to someone with FTP or File Manager (via your hosting's cPanel) access. If you don't give your theme files to anyone, they are all your own. As long as you keep your FTP access secure, your theme's files will be secure.


0

For me, I offer you a solution composed of three parts: 1 - Create a CTP. 2 - Create the necessary javascript and css scripts. 3 - Create a dedicated template in the root of your theme archive-$posttype.php, in our example will be archive-product.php I created a repo in my git where you can download the Plugin here is the link: Custom CPT The source ...


0

Rather than just no-indexing the Page, 301 redirect it. This can be done either by server config (.htaccess, NGINX rules, etc.) or using a plugin. That way no one can actually get to the Page all on its own - it only exists on the front page.


0

You should leave the "content" of a page to the actual content, that is text and images. You shouldn't be pasting custom html, as it is very easy to break and hard to maintain. If you have custom html for a page and don't care about editing it yourself directly, you should be using custom page templates. You can learn about them here: https://developer....


0

If you're set to a static front page, why would there be pagination? The proper way to have a paginated grid of posts as your front page is to set the homepage to "Your latest posts". You would then develop your front-page.php, home.php or index.php template to display posts as a grid (use the Template Hierarchy to determine which file you need). In that ...


0

I want to understand if I can write my own templates using only the conditional tags, or if i need to maintain the actual structure of the templates that include a lot of do_action() and less markup, I've not modified them, just copied inside the mytheme/woocommerce/ folder of my theme for now. WooCommerce extensions all make extensive use of those ...


1

To answer your second question you'll have to properly enqueue the Bootstrap 4 styles and scripts: Including CSS & JavaScript | Theme Development From there you either have to add existing WooCommerce classes to your BootStrap CSS or add BootStrap classes to your WooCommerce templates (preferred/recommended). As for the templates, it really depends on ...


0

You should be able to get the current index in loop from the global $wp_query object. With the help of modulo you can then set an alternating css class for a post. global $wp_query; while ( have_posts() ) { the_post(); $alignment = ( ($wp_query->current_post + 1) % 2 === 0 ) ? 'even align-right': 'odd align-left'; // post html markup with class="&...


1

function wp_dequeue_kirki_style() { wp_dequeue_style('kirki-styles'); } add_action('wp_enqueue_scripts', 'wp_dequeue_kirki_style'); Please make sure that you have handler name kirki-styles in the parent theme for the css file that you want to remove. Because wp_dequeue_style function used handler as parameter. You can check documentaion of dequeue ...


1

Your analysis of the problem is absolutely right. By having separate autoloaders in the theme and plugin you'll run into conflicts and only the first one being loaded. There is no easy and general solution to this, but if you control the whole stack the best solution probably is to put the whole site including WP under composer management and define the ...


0

You can use the_modified_time( $format ) in the loop, where $format is the PHP date/time format. If left empty it'll show in the format from your site settings.


0

Some quick possibe solutions working in templates: If you have a page template for the homepage you can output somewhere <?php echo "Last modified on: ".$post->post_modified; ?> If you work on index.php of your theme <?php if ( is_home() || is_front_page()){echo "Last modified on: ".$post->post_modified;}?> The first example above can ...


0

I figured out a "down and dirty" fix in the theme code. This will be overridden when you update the theme so you'll have to do it again at that time. themes/Divi/includes/builder/scripts/frontend-builder-scripts.js Lines 1316 - 1330 if ( et_is_mobile_device ) { $( '.et_pb_section_video_bg' ).each( function() { var $this_el = $(this); $...


0

You can find here the solution: https://developer.wordpress.org/themes/basics/template-hierarchy/#category Rendering category archive index pages uses the following path in WordPress: category-{slug}.php – If the category’s slug is news, WordPress will look for category-news.php. category-{id}.php – If the category’s ID is 6, WordPress will look ...


0

https://wordpress.org/support/topic/remove-inline-styles-5/ add_action( 'wp_enqueue_scripts', function() { $styles = wp_styles(); $styles->add_data( 'twentytwenty-style', 'after', array() ); }, 20 );


2

You can modify the request by adding the orderby parameter: modified $args = [ 'orderby' => 'modified', 'order' => 'DESC', ]; $query = new WP_Query( $args ); WP_query Order & Orderby Parameters


0

You could avoid the warning by adding the seventh parameter as null. function fivehundred_register_admin_menu() { add_theme_page('500 Settings', '500 Settings', 'manage_options', 'theme-settings', 'fivehundred_admin_menu', plugins_url( '/ignitiondeck/images/ignitiondeck-menu.png'), null); } add_action('admin_menu', 'fivehundred_register_admin_menu');


2

The file needs a template header and will only behave as a user-selectable custom page template. True special templates like page-$slug.php that match the post's slug will only work when they live in the root theme directory.


0

Use a meta query. Since ACF stores dates as Ymd you can just treat the value as a number: $date_query = array( 'key' => 'start_date', // ACF date field name 'type' => 'NUMERIC', 'value' => '20200101', 'compare' => '<=', // All posts with start date before/on January 1st 2020 ); $args['meta_query'] = array( $date_query ); Any ...


-1

Maybe u should switch using another builder, you can combine 2 plugin functionality with this : Elementor Pro (is your base/main plugin for builder). JetEngine by Crocoblock. (will be like an addon to make specific template with custom post type functionality and custom field). Personally i just switch to both of them from WP Bakery.


0

Start by reading the developer docs here: https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#how-the-readme-is-parsed . The example readme on that page explains all of what is required, what to put there, and the other optional items. There are also several readme generators that might help you. One is here: https://tools....


0

the_custom_logo() displays a custom logo image, linked to home, so you don't need to echo it, wrap it inside a tag or use it as a src for an image. If you want to use the default output, then just use in your theme file. If there's no custom logo set, then the function results in an empty string i.e. nothing is displayed. For custom output, first get the ...


0

Just to expand on Jacob Peattie Answer for people that have CSS file in a custom plugin, you can use filemtime( plugin_dir_path(dirname(__FILE__)).'plugin-folder/css-file-path.css' )


0

You can upload file using ajax using below code: First : Add attributes name="f-form" and id="f-form" in your <form> tag. After that, In js script, get form data using new FormData() and send to ajax data, Note : change url: ajax_object.ajaxurl with your ajax url path jQuery(document).ready(function(e) { jQuery('#f-submit').on('click', ...


1

Call me silly, but just found a way of getting it enqueued without having it as duplicate. @cjbj, I do really appreciate your help! If you enqueue it in the child theme's function.php file (at the end of the stylesheets enqueued in there for priority sake) and make sure you use the exact same handle as the theme is registering it with (look it up in the ...


1

You can use below code to display theme detail sentence. I have use wp_footer action,You can change hook as per your requirement. function logbook_info() { $theme_logbook = wp_get_theme(); $theme_name = esc_html( $theme_logbook->get( 'Name' ) ); $theme_uri = esc_html( $theme_logbook->get( 'ThemeURI' ) ); $theme_author = esc_html( $...


0

function logbook_info() { $theme_logbook = wp_get_theme(); echo 'The'.esc_html( $theme_logbook->get( 'TextDomain' ) ). 'Developed by '. esc_html( $theme_logbook->get( 'AuthorURI' ) ); } add_action( 'logbookinfo', 'logbook_info' ); Try this.


1

Are you sure the version is included in style.css in the right way? In that case this should really work (hook with wp_enqueue_scripts): $theme_data = wp_get_theme(); wp_register_style('your-style-handle', get_template_directory_uri() . '/style.css', '', $theme_data['version'], 'all'); wp_enqueue_style('your-style-handle'); While developing you ...


Top 50 recent answers are included