Skip to content

Instantly share code, notes, and snippets.

@AliNaraghiA
AliNaraghiA / endpoint that returns all categories
Created June 8, 2023 07:14
custom REST endpoint that returns all categories for posts in WordPress:
<?php
/**
* Plugin Name:Ali Custom API
* Plugin URI:
* Description: Crushing
* Version: 1.0
* Author: Ali
* Author URI:
*/
@AliNaraghiA
AliNaraghiA / endpoint that returns category with post id
Created June 8, 2023 07:21
give the post id and returns the category
<?php
/**
* Plugin Name:Ali Custom API
* Plugin URI:
* Description: Crushing
* Version: 1.0
* Author: Ali
* Author URI:
*/
<?php
/**
* Plugin Name:Ali Custom API
* Plugin URI:
* Description: Crushing
* Version: 1.0
* Author: Ali
* Author URI:
*/
function get_all_category_names( $request ) {
@AliNaraghiA
AliNaraghiA / endpoint that returns custom api with category
Created June 8, 2023 07:36
returns custom api with category *chanfe the Fa to any thing you want. i use this for multiple language site
<?php
/**
* Plugin Name:Ali Custom API
* Plugin URI:
* Description: Crushing
* Version: 1.0
* Author: Ali
* Author URI:
*/
add_action( 'rest_api_init', 'register_custom_endpoints' );
request('http://your-wordpress-site.com/graphql', query)
.then(data => console.log(data))
.catch(error => console.error(error))
<template>
<div>
<h1>All Posts</h1>
<ul>
<li v-for="post in posts" :key="post.databaseId">
<h2>{{ post.title }}</h2>
<p>{{ post.excerpt }}</p>
<img v-if="post.featuredImage" :src="post.featuredImage.node.sourceUrl" alt="Featured Image" />
</li>
</ul>
@AliNaraghiA
AliNaraghiA / nuxt.js
Created July 11, 2023 13:13
store post meta in WPGraphQL
add_action( 'graphql_register_types', function() {
register_graphql_field( 'Post', 'color', [
'type' => 'String',
'description' => __( 'The color of the post', 'wp-graphql' ),
'resolve' => function( $post ) {
$color = get_post_meta( $post->ID, 'color', true );
return ! empty( $color ) ? $color : 'blue';
}
] );
} );
@AliNaraghiA
AliNaraghiA / houses.csv
Last active December 11, 2023 07:47 — forked from anonymous/houses.csv
Tables in Medium
مشخصات ویژگی
19 - 33 ولتاژ
پلی اتیلن کراس لینک نیمه رسانا اسکرین هادی
8 میلی متر ضخامت عایق
90+ سانتی گراد حداکثر دمای کار هادی
XLPE عایق
سیم آلومینیومی جنس آرمور کابل تک هسته
سیم فولادی جنس آرمور کابل چند هسته
پی وی سی روکش استاندارد BS6622
LSZH روکش استاندارد BS7835