admin管理员组

文章数量:1417442

when i go to wp customizer then i want edit the name popular and cat_id =21


<div class="p_list"><h2><span>popular</span></h2>   
    <?php $first = true; ?> <?php $cat_id = 21;
$latest_cat_post = new WP_Query( array('posts_per_page' => 4, 'category__in' => array($cat_id)));
if( $latest_cat_post->have_posts() ) : while( $latest_cat_post->have_posts() ) : $latest_cat_post->the_post();  ?>  

when i go to wp customizer then i want edit the name popular and cat_id =21


<div class="p_list"><h2><span>popular</span></h2>   
    <?php $first = true; ?> <?php $cat_id = 21;
$latest_cat_post = new WP_Query( array('posts_per_page' => 4, 'category__in' => array($cat_id)));
if( $latest_cat_post->have_posts() ) : while( $latest_cat_post->have_posts() ) : $latest_cat_post->the_post();  ?>  
Share Improve this question edited Aug 6, 2019 at 21:35 abdullahsk asked Aug 6, 2019 at 20:43 abdullahskabdullahsk 12 bronze badges 1
  • Note that you can do something a plugin does without a plugin, by copy pasting it into a theme and deleting the comment at the top, then including it from functions.php. Your site won't be any faster though, you'll have just made it more complicated. Otherwise I'm not sure I understand your question, can you reword it? Also can you reformat your code? It's very difficult to read, and has no indentation, all the PHP is on a single line – Tom J Nowell Commented Aug 6, 2019 at 21:14
Add a comment  | 

1 Answer 1

Reset to default -1

The customizer, as it is mostly for style settings.

If you want to make a heading dynamic then you could create a custom field. Then echo that into the page or post template using the get_post_meta function, and wrap it in whatever HTML tags you wish.

Hope this helps!

check these out:

https://wordpress/support/article/custom-fields/

https://wordpress/support/article/custom-fields/#displaying-custom-fields

Or you could try these plugins:

https://wordpress/plugins/meta-box/

https://wordpress/plugins/advanced-custom-fields/

本文标签: codexhow do i add customizer edit option without plugin in wp