wordpress-theming

How to initialize $id from another function?

╄→гoц情女王★ 提交于 2019-12-23 03:03:54
问题 I would like to use $id to echo the id entered in other functions. Here is an example function using id: function nl_register_ga_code() { // Validation callback register_setting( 'nl_theme_options', 'nl_theme_options', 'nl_validate_settings' ); // Add setting to section add_settings_section( 'nl_footer_section', 'Footer', 'nl_display_footer_section', 'nl_theme_options.php' ); // Create textarea field $field_args = array( 'type' => 'textarea', 'id' => 'nl_ga_code', 'name' => 'nl_ga_code',

wp_list_pages isnt showing title attribute

↘锁芯ラ 提交于 2019-12-23 02:36:29
问题 I'm using wordpress on my site and for some reason the wp_list_pages() isn't showing a title attribute? I'd love to add it for the SEO purposes. Any help? My current code is wp_list_pages('depth=1&title_li=&exclude=9'); 回答1: wp_list_pages() not supposed to have a title attribute by default. You can always write your own functions if the given functions don't fit your needs. <?php function mytheme_list_pages($param) { $pages = get_pages($param); foreach ( $pages as $page ) { $li = '<li><a href

Display page content using multiple templates - WordPress

我们两清 提交于 2019-12-22 13:57:24
问题 Is it possible to have a page like: www.site.com/page/ and show different templated versions using, say: www.site.com/page/?template=default www.site.com/page/?template=archive ...? So it retrieves the same page content but displays it differently. Is this possible with WordPress? Is it standard or would need some tomhackery to do this? Thank you 回答1: Create a 'master' template and assign it to your page. The master template doesn't contain any layout information—just a set of conditional

Add multiple dates to custom post type in Wordpress

梦想的初衷 提交于 2019-12-22 12:27:13
问题 I am building a Wordpress site with pages, posts and events (with multiple dates you can sign in). I am new to Wordpress so I was looking for ideal solution for this events. I believe the best solution is to create custom post type called "Event" and then handle it separately. I am not sure however how to add multiple dates to each event. I have been reading about custom taxonomies and post metadata but every example I went through was like creating a custom category, tag or adding a single

wordpress sticky post on archive page with pagination

送分小仙女□ 提交于 2019-12-22 10:45:45
问题 I have category page which is redirecing to archieve.php. you can see here : https://www.dealfinder.lk/category/dining/ There are two sticky posts at the top. 1) Up to 25% OFF at &Co Pub and Kitchen with COMBANK Cards 2) 20% OFF at Robata – Movenpick Hotel Colombo for all HSBC Credit Cards My pagination is 10 items per post Right now, it shows me 12 items per post . Here is my code : function yell_category_sticky_posts( $posts, $wp_query ) { global $wp_the_query; // Don't continue if this isn

WordPress jQuery Uncaught TypeError: Property '$' of object [object Object] is not a function

给你一囗甜甜゛ 提交于 2019-12-22 05:36:19
问题 I'm converting my html files to a WordPress theme and I'm using the plugin ZClip for copy text to clipboard. The ZClip plugin works fine in my html demo, but when converting to WordPress I got this weird syntax error "Uncaught TypeError: Property '$' of object [object Object] is not a function" in line 288 in the zclip.js file which is $(this.domElement).data('zclipId', 'zclip-' + this.movieId); I think it is something with the variable $ not sure. I read something about the jQuery might get

wp_enqueue_style and rel other than stylesheet?

白昼怎懂夜的黑 提交于 2019-12-22 04:27:06
问题 I create (or better try) to create my first WordPress theme with Less. What I do is to use a script like that into my functions.php wp_register_style('screen_css', get_bloginfo('template_url') . '/css/screen.less', array(), false, 'screen'); wp_enqueue_style('screen_css'); and the result is that: <link rel='stylesheet' id='stigma_screen-css' href='http://www.stigmahost.dch/wp-content/themes/stigmahost/css/screen.less?ver=1.0' type='text/css' media='screen' /> The question is, can I change

Wordpress use functions.php to run function only on specific page template

笑着哭i 提交于 2019-12-22 00:32:05
问题 I have a following code to check if current used file is tmp_home_page.php , but when I do echo $template_file; it is showing functions.php add_action('template_redirect', 'are_we_home_yet', 10); function are_we_home_yet(){ global $template; $template_file = basename((__FILE__).$template); if ( is_home() && $template_file == 'tmp_home_page.php' ) { // do stuff } } Any idea how to make sure that my do stuff is only run on home page and when given template is in use? 回答1: You're looking way too

How to save multiple checkbox on update post meta in wordpress?

徘徊边缘 提交于 2019-12-21 23:28:38
问题 I'm having multiple check boxes and I want to save the check box and also update it in the update_post_meta so that next time when a user edit the post, he would know which check boxes are already checked. I don't know where am I getting wrong. Here is my code: add_action( 'add_meta_boxes', 'add_custom_box' ); function add_custom_box( $post ) { add_meta_box( 'Meta Box', // ID, should be a string 'Music', // Meta Box Title 'music_meta_box', // Your call back function, this is where your form

My settings are not saving in wordpress theme options page

我是研究僧i 提交于 2019-12-21 22:34:12
问题 I am trying to create a theme options page based on WordPress's Settings API. When I go to check the options.php page in my browser (ex. http://mysite.com/wordpress/wp-admin/options.php), I see an entry for coolorange_options but it is empty. This happened after I added a url, width and height to the text fields. So far, I have enough code written to get the information and store it to the database, but not to retrieve it for anything. I referenced a tutorial in the php comment at the top of